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
ordinalintThe signed ordinal position of the day within the year.
Exceptions
- ArgumentOutOfRangeException
ordinalis 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
yearintThe Gregorian year in which to calculate the occurrence.
contextStrategyResolutionContextThe resolution context used by referential strategies to resolve other rules.
Returns
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |