Skip to content

Construct a DateRange

Construct a DateRange from various inputs with sentinel defaulting, triggered when caller creates a range.

Field Value
Operation ID OP-014
Trigger Caller creates a range
Inputs none / IDateRange / DateTime / DateTime, DateTime
Outputs DateRange instance
Primary components DateRange` constructors (4 overloads) and `DateRange.Empty
Entry point Common/SAIF.Common/Classes/DateRange.cs

Steps

  1. Parameterless ctor: set BeginDate = DateTime.MinValue, EndDate = DateTime.MaxValue — the canonical unbounded range. (BR-002, BR-032)
  2. Copy ctor: copy BeginDate/EndDate from the supplied IDateRange (no null guard).
  3. Begin-only ctor: set the supplied begin date and default EndDate to DateTime.MaxValue (open-ended forward). (BR-032)
  4. Two-date ctor: assign both, then coerce EndDate to DateTime.MaxValue when the caller passed DateTime.MinValue — a MinValue end means "no end date". (BR-033)
  5. DateRange.Empty is a cached static parameterless-constructed instance (MinValue..MaxValue). (BR-032)

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start(["Caller constructs<br>a DateRange"]) --> S1["Parameterless ctor: BeginDate=MinValue,<br>EndDate=MaxValue"]
    S1 --> S2["Copy ctor: copy BeginDate/EndDate<br>from supplied IDateRange"]
    S2 --> S3["Begin-only ctor: set begin date,<br>default EndDate to MaxValue"]
    S3 --> D1{"Two-date ctor: EndDate<br>supplied as MinValue?"}
    D1 -->|Yes| S4a["Coerce EndDate<br>to MaxValue"]
    D1 -->|No| S4b["Assign both dates<br>as supplied"]
    S4a --> S5
    S4b --> S5["DateRange.Empty: cached<br>static instance (MinValue..MaxValue)"]
    S5 --> End([Return DateRange instance])

Sources

  • Common/SAIF.Common/Classes/DateRange.cs