Table of Contents

NotableDateSequenceExtensions Class

Definition

Namespace
Bodu.Globalization.Calendar
Assembly
Bodu.Globalization.Calendar.dll
Package
Bodu.Globalization.Calendar 1.0.1
Source
NotableDateSequenceExtensions.cs

Provides extension methods that transform resolved occurrence sequences, such as expanding observed-only results into a timeline that also contains each adjusted occurrence's originally calculated date.

public static class NotableDateSequenceExtensions
Inheritance
NotableDateSequenceExtensions
Inherited Members

Examples

// 2021: Christmas Day (Sat 25th) and Boxing Day (Sun 26th) were both observed on the following
// working days, so an observed-only pack returns occurrences dated 27 and 28 December.
IReadOnlyList<NotableDate> resolved = service.Resolve(
    new DateRange(new DateOnly(2021, 12, 24), new DateOnly(2021, 12, 29)), "AU");

// Expand to the full timeline: 25 and 26 December reappear as actual occurrences.
IReadOnlyList<NotableDate> timeline = resolved.WithActualOccurrences();

Remarks

Resolution emits occurrences per the winning adjustment policy's EmissionMode. Data packs that emit ObservedOnly return a single occurrence per adjusted notable date, anchored on the observed date, with the originally calculated date carried only in ActualDate. The extensions here reconstruct the fuller ActualAndObserved view from such results without re-running resolution.

Methods

WithActualOccurrences(IReadOnlyList<NotableDate>)

Returns the occurrences together with a synthesized actual occurrence for every observed occurrence whose originally calculated date is absent from the sequence.

public static IReadOnlyList<NotableDate> WithActualOccurrences(this IReadOnlyList<NotableDate> occurrences)

Parameters

occurrences IReadOnlyList<NotableDate>

The resolved occurrences to expand.

Returns

IReadOnlyList<NotableDate>

The occurrences plus the synthesized actual occurrences, ordered by date, then notable-date id, then rule id (ordinal) - the same ordering contract as Resolve(DateRange, string). When no occurrence requires expansion, the input instance is returned unchanged.

Remarks

An occurrence is expanded when IsObserved is true and ActualDate is non-null and differs from Date. The synthesized occurrence matches the shape the resolution engine emits for the actual half of ActualAndObserved: it is dated on the calculated date with ActualDate equal to that date, IsObserved is false, and AdjustmentPolicyId and AdjustmentReason are cleared; all other fields, including DisplayName, carry over unchanged.

Synthesis is skipped when the sequence already contains an occurrence with the same Identity on the calculated date, so the method is idempotent and is a no-op for results produced under ActualAndObserved.

A synthesized date can precede the range the sequence was resolved for (an observed occurrence inside the range may have been calculated before it). Apply InDateRange(DateOnly, DateOnly) to the result when strict range containment is required. The expansion is a pure sequence transform: the source resource's same-day collision policy is not re-applied to the synthesized occurrences.

Exceptions

ArgumentNullException

occurrences is null.

Applies to

ProductVersions
.NET8, 10

See Also