Skip to content

Compare two date ranges for equality

Compare two date ranges for structural equality, triggered when caller compares ranges.

Field Value
Operation ID OP-015
Trigger Caller compares ranges
Inputs Two ranges
Outputs Boolean / int
Primary components DateRange.operator ==` / `operator !=` / `Equals(object)` / `GetHashCode()`, and `DateRangeExtensions.IsEqual
Entry point Common/SAIF.Common/Classes/DateRange.cs

Steps

  1. operator ==(DateRange d1, IDateRange d2) returns true only when both BeginDate and EndDate match. (BR-034)
  2. operator != independently returns true when either endpoint differs — it is not implemented as !(==). (BR-034)
  3. Equals(object obj) type-checks for IDateRange and defers to operator ==; anything else returns false. (BR-034)
  4. GetHashCode() returns the arithmetic sum of the two endpoint hash codes.
  5. DateRangeExtensions.IsEqual(range1, range2) performs the same endpoint comparison but additionally null-guards range2, returning false when it is null. (BR-034)

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start(["Caller compares<br>two date ranges"]) --> S1["operator ==: true only when<br>both BeginDate and EndDate match"]
    S1 --> S2["operator !=: independently checks<br>if either endpoint differs"]
    S2 --> S3["Equals(object): type-checks<br>IDateRange, defers to operator =="]
    S3 --> S4["GetHashCode(): sum of<br>both endpoint hash codes"]
    S4 --> S5["IsEqual: same comparison,<br>null-guards range2"]
    S5 --> End([Return comparison result])

Failure and edge-case behavior

  • The operators dereference both operands without null checks, so comparing against null raises NullReferenceException.*

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/Classes/DateRange.cs
  • Common/SAIF.Common/Extensions/DateRangeExtensions.cs