Table of Contents

DailyIntervalRecurrenceStrategy Class

Definition

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

Generates an occurrence every fixed number of calendar days from an anchor date, such as every 14 days from 1 January 2026.

public sealed class DailyIntervalRecurrenceStrategy : IDateRecurrenceStrategy
Inheritance
DailyIntervalRecurrenceStrategy
Implements
Inherited Members
Extension Methods

Remarks

The anchor is occurrence zero; no occurrence before the anchor is produced. Alignment into the requested window is computed directly from the anchor via NextOccurrence(DateOnly, int, DateOnly), so a distant anchor never forces per-day iteration. A window that starts exactly on an aligned occurrence includes that occurrence.

// Every 14 days from 1 January 2026 (fortnightly).
var recurrence = new DailyIntervalRecurrenceStrategy(new DateOnly(2026, 1, 1), 14);

Constructors

DailyIntervalRecurrenceStrategy(DateOnly, int)

Initializes a new instance of the DailyIntervalRecurrenceStrategy class.

public DailyIntervalRecurrenceStrategy(DateOnly anchorDate, int intervalDays = 1)

Parameters

anchorDate DateOnly

The anchor date that defines occurrence zero and the phase of the series.

intervalDays int

The number of calendar days between consecutive occurrences.

Exceptions

ArgumentOutOfRangeException

intervalDays is less than one.

Properties

AnchorDate

Gets the anchor date that defines occurrence zero and the phase of the series.

public DateOnly AnchorDate { get; }

Property Value

DateOnly

The anchor date.

IntervalDays

Gets the number of calendar days between consecutive occurrences.

public int IntervalDays { get; }

Property Value

int

The interval in days.

Methods

GetOccurrences(DateRange, StrategyResolutionContext)

Calculates the occurrences of the recurrence that fall within the supplied inclusive date range.

public IEnumerable<DateOnly> GetOccurrences(DateRange range, StrategyResolutionContext context)

Parameters

range DateRange

The inclusive window to generate occurrences within.

context StrategyResolutionContext

The resolution context for referential lookups.

Returns

IEnumerable<DateOnly>

The occurrences within range in ascending chronological order, without duplicates; an empty sequence when the recurrence produces no occurrence in the window.

Applies to

ProductVersions
.NET8, 10

See Also