Table of Contents

DayOfYearStrategy Class

Definition

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

Calculates a date by its ordinal position within a Gregorian year, such as the 100th day or the final day of the year.

public sealed class DayOfYearStrategy : IDateCalculationStrategy
Inheritance
DayOfYearStrategy
Implements
Inherited Members
Extension Methods

Remarks

A positive ordinal counts from 1 January (1 is 1 January); a negative ordinal counts from 31 December (-1 is 31 December). A positive ordinal beyond the number of days in the year produces no occurrence, so day 366 exists only in a leap year.

// The 256th day of the year (Programmers' Day).
var strategy = new DayOfYearStrategy(256);

Constructors

DayOfYearStrategy(int)

Initializes a new instance of the DayOfYearStrategy class.

public DayOfYearStrategy(int ordinal)

Parameters

ordinal int

The signed ordinal position of the day within the year.

Exceptions

ArgumentOutOfRangeException

ordinal is zero or has an absolute value greater than 366.

Properties

Ordinal

Gets the signed ordinal position of the day within the year.

public int Ordinal { get; }

Property Value

int

The ordinal; positive counts from 1 January, negative from 31 December.

Methods

Calculate(int, StrategyResolutionContext)

Calculates the occurrence of the notable date in the supplied Gregorian year.

public DateOnly? Calculate(int year, StrategyResolutionContext context)

Parameters

year int

The Gregorian year in which to calculate the occurrence.

context StrategyResolutionContext

The resolution context used by referential strategies to resolve other rules.

Returns

DateOnly?

The calculated occurrence, or null when the strategy produces no occurrence in year (for example a 29 February rule in a non-leap year).

Applies to

ProductVersions
.NET8, 10

See Also