Skip to content

Intersect() should be Combine() or such #1

@grayed

Description

@grayed

public static DateTimeRange Intersect(this DateTimeRange first, DateTimeRange second) =>

This is not an intersection, it's rather a union. Intersection is a common part of two ranges, which may ever be empty.

Since DateTimeRange Intersect(this DateTimeRange first, DateTimeRange second) API is public now, I suggest the following:

  1. Implement DateTimeRange? IntersectWith(this DateTimeRange first, DateTimeRange second) which does the right thing.
  2. Implement DateTimeRange CombineWith(this DateTimeRange first, DateTimeRange second) which does what current DateTimeRange Intersect(this DateTimeRange first, DateTimeRange second) does.
  3. Drop the DateTimeRange Intersect(this DateTimeRange first, DateTimeRange second) method, pushing the major library number, so that people would expect breakage upon version change.

I can do this if you agree on this direction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions