Table of Contents

DateRangeCoverage Class

Definition

Namespace
Bodu.Financial.ExchangeRates
Assembly
Bodu.Financial.dll
Package
Bodu.Financial 1.0.0
Source
DateRangeCoverage.cs

Tracks the set of DateOnly ranges that have actually been observed, as a sorted list of disjoint inclusive intervals that merge on insertion but never bridge a gap.

public sealed class DateRangeCoverage
Inheritance
DateRangeCoverage
Inherited Members
Extension Methods

Remarks

The type answers one question precisely: has every day in a requested window already been seen? Unlike a single (min, max) envelope, it preserves interior gaps, so a window that straddles an unobserved stretch is correctly reported as not covered. Two intervals are merged only when they overlap or touch - the later interval begins on or before the day after the earlier one ends - so a genuine gap of one or more days keeps them separate.

Instances are not thread-safe; callers that mutate a shared instance must synchronize access themselves.

Constructors

DateRangeCoverage()

public DateRangeCoverage()

Properties

Intervals

Gets the recorded intervals in ascending order.

public IReadOnlyList<(DateOnly Start, DateOnly End)> Intervals { get; }

Property Value

IReadOnlyList<(DateOnly Start, DateOnly End)>

The disjoint inclusive intervals that make up the coverage, ordered by start date.

IsEmpty

Gets a value indicating whether no range has been recorded.

public bool IsEmpty { get; }

Property Value

bool

true when no interval has been added; otherwise false.

Methods

Add(DateOnly, DateOnly)

Records the inclusive range start..end as observed, merging it with any overlapping or adjacent intervals already present.

public void Add(DateOnly start, DateOnly end)

Parameters

start DateOnly

The inclusive first date of the observed range.

end DateOnly

The inclusive last date of the observed range.

Exceptions

ArgumentOutOfRangeException

Thrown when start is later than end.

Contains(DateOnly)

Reports whether the supplied date has been recorded.

public bool Contains(DateOnly date)

Parameters

date DateOnly

The date to test.

Returns

bool

true when a recorded interval contains date; otherwise false.

Contains(DateOnly, DateOnly)

Reports whether every day in the inclusive range start..end has been recorded.

public bool Contains(DateOnly start, DateOnly end)

Parameters

start DateOnly

The inclusive first date of the window to test.

end DateOnly

The inclusive last date of the window to test.

Returns

bool

true when a single recorded interval fully contains the window; otherwise false.

Exceptions

ArgumentOutOfRangeException

Thrown when start is later than end.

Applies to

ProductVersions
.NET8, 10