Determine whether two date ranges overlap¶
Test whether two date ranges intersect, triggered when caller compares two IDateRange instances.
| Field | Value |
|---|---|
| Operation ID | OP-003 |
| Trigger | Caller compares two IDateRange instances |
| Inputs | range1, range2, inAllowSameDateOverlap |
| Outputs | Boolean |
| Primary components | DateRangeExtensions.IsOverlapping(this IDateRange, IDateRange, Boolean inAllowSameDateOverlap = false) |
| Entry point | Common/SAIF.Common/Extensions/DateRangeExtensions.cs |
Steps¶
- Translate
inAllowSameDateOverlapinto anIncludeComparisonsmode:true→Exclusive(touching endpoints are not an overlap),false→Inclusive. (BR-004) - Guard: proceed only if
range2is non-null and both ranges passIsValidRange(). Otherwise returnfalse. (BR-001, BR-002) - Return
trueif any of four conditions hold:range2.BeginDatefalls inside range1;range2.EndDatefalls inside range1;range1.BeginDatefalls inside range2; or the ranges are exactly identical and not zero-length. Membership is evaluated byIComparableExtensions.IsBetweenusing the mode from step 1. (BR-003, BR-004) - Otherwise return
false.
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([IsOverlapping called]) --> S1["Translate inAllowSameDateOverlap<br>into comparison mode"]
S1 --> D1{"range2 non-null and<br>both ranges valid?"}
D1 -->|No| R1([Return false])
D1 -->|Yes| D2{"Any of 4 overlap<br>conditions true?"}
D2 -->|Yes| R2([Return true])
D2 -->|No| R3([Return false])
Related documentation¶
Sources¶
Common/SAIF.Common/Extensions/DateRangeExtensions.cs