Table of Contents

INotableDateAlgorithm Interface

Definition

Namespace
Bodu.Globalization.Calendar.Algorithms
Assembly
Bodu.Globalization.Calendar.dll
Package
Bodu.Globalization.Calendar 1.0.1
Source
INotableDateAlgorithm.cs

Computes the date of a notable date for a Gregorian year from a closed-form or tabular algorithm. Implementations are registered under a key and dispatched by the AlgorithmDateStrategy when a rule references that key, allowing the algorithm catalogue to be extended beyond the built-in computations.

public interface INotableDateAlgorithm
Extension Methods

Examples

// A custom algorithm returning the March equinox (UTC) for the supplied year.
public sealed class MarchEquinoxAlgorithm : INotableDateAlgorithm
{
    public DateOnly? Calculate(int year) =>
        year is >= 1900 and <= 2100
            ? DateOnly.FromDateTime(AstronomyTables.MarchEquinox(year))
            : null; // unsupported year: return null rather than throw
}

Remarks

Implementations must be deterministic, side-effect-free, and thread-safe, and should return null for a year outside their supported range rather than throwing.

When to implement. Provide a custom algorithm when a notable date follows a computation the built-in strategies do not cover - for example an astronomical event or a bespoke ecclesiastical rule. Register the implementation under a key in an INotableDateAlgorithmRegistry, pass that registry to the loader and the NotableDateService, and reference the key from a rule's algorithm strategy.

Methods

Calculate(int)

Calculates the occurrence for the supplied Gregorian year.

DateOnly? Calculate(int year)

Parameters

year int

The Gregorian year to calculate against.

Returns

DateOnly?

The occurrence date, or null when the year is unsupported.

Applies to

ProductVersions
.NET8, 10

See Also