DailyIntervalRecurrenceStrategy Class
Definition
- Namespace
- Bodu.Globalization.Calendar.Algorithms
- Assembly
- Bodu.Globalization.Calendar.dll
- Package
- Bodu.Globalization.Calendar 1.0.1
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
anchorDateDateOnlyThe anchor date that defines occurrence zero and the phase of the series.
intervalDaysintThe number of calendar days between consecutive occurrences.
Exceptions
- ArgumentOutOfRangeException
intervalDaysis 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
rangeDateRangeThe inclusive window to generate occurrences within.
contextStrategyResolutionContextThe resolution context for referential lookups.
Returns
- IEnumerable<DateOnly>
The occurrences within
rangein ascending chronological order, without duplicates; an empty sequence when the recurrence produces no occurrence in the window.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |