---
title: Determine whether a sequence of date ranges overlaps itself
summary: Detect mutual overlap within a collection of date ranges.
status: draft
owner: saif-docgen
last_reviewed: 2026-09-15
library: SAIF.Framework.Common
reference_type: package
operation_id: OP-005
trigger: Caller validates a set of periods for mutual exclusivity
---

# Determine whether a sequence of date ranges overlaps itself

Detect mutual overlap within a collection of date ranges, triggered when caller validates a set of periods for mutual exclusivity.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-005 |
| **Trigger** | Caller validates a set of periods for mutual exclusivity |
| **Inputs** | `ranges`, `option` |
| **Outputs** | `Boolean` |
| **Primary components** | ``DateRangeExtensions.IsOverLapping(this IEnumerable<IDateRange>, OverlappingOptions option = DatesMayNotMatch)`` |
| **Entry point** | `Common/SAIF.Common/Extensions/DateRangeExtensions.cs` |

## Steps

1. If fewer than two ranges are supplied, return `false`. ([BR-008](../business-rules.md#br-008-a-set-of-fewer-than-two-date-ranges-never-self-overlaps))
2. Order ranges ascending by `BeginDate`.
3. Skip ranges whose begin and end are both sentinel values (`DateTime.MinValue`/`MaxValue`) — treated as a "null date" and ignored (`DateExtensions.IsMinOrMax`). ([BR-002](../business-rules.md#br-002-a-range-is-%22open-ended%22-when-begindate-is-datetime.minvalue-or-enddate-is-datetime.maxvalue), [BR-009](../business-rules.md#br-009-a-range-whose-begin-and-end-are-both-sentinel-values-is-treated-as-a-null-date-and-ignored-during-collection-overlap-evaluation))
4. If the previous range is open-ended (`IsOpenEnded`) and the current range has a real begin date, return `true` immediately — an open-ended range swallows everything after it. ([BR-002](../business-rules.md#br-002-a-range-is-%22open-ended%22-when-begindate-is-datetime.minvalue-or-enddate-is-datetime.maxvalue), [BR-010](../business-rules.md#br-010-an-open-ended-predecessor-followed-by-any-range-with-a-real-begin-date-is-always-an-overlap))
5. Branch on `option`: `DatesMayMatch` reports overlap when `range.BeginDate < previous.EndDate`; `DatesMayNotMatch` (default) reports overlap when `range.BeginDate <= previous.EndDate`, so touching endpoints count as an overlap. ([BR-011](../business-rules.md#br-011-the-default-collection-overlap-mode-is-datesmaynotmatch))
6. Advance `previous`; return `false` if the loop completes with no overlap found.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([IsOverLapping called]) --> D1{"Fewer than<br>2 ranges supplied?"}
	D1 -->|Yes| R1([Return false])
	D1 -->|No| S1["Order ranges ascending<br>by BeginDate"]
	S1 --> S2["Skip ranges with sentinel<br>begin/end (null date)"]
	S2 --> D2{"Previous open-ended and<br>current has real begin date?"}
	D2 -->|Yes| R2([Return true])
	D2 -->|No| D3{"Overlap per<br>selected option?"}
	D3 -->|Yes| R3([Return true])
	D3 -->|No| S3["Advance previous,<br>continue loop"]
	S3 --> End([Return false])
```

## Failure and edge-case behavior

- The `switch` in step 5 sits outside the first/skip branch structure, so it also executes on the first iteration while `previous` is still `null`, which would raise a `NullReferenceException`.*

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.

## Sources
- `Common/SAIF.Common/Extensions/DateRangeExtensions.cs`
