OrdinalDayOfMonthStrategy Class
Definition
- Namespace
- Bodu.Globalization.Calendar.Algorithms
- Assembly
- Bodu.Globalization.Calendar.dll
- Package
- Bodu.Globalization.Calendar 1.0.1
Calculates a day by its ordinal position from the beginning or end of a Gregorian month, such as the last day of February or the second-last day of a month.
public sealed class OrdinalDayOfMonthStrategy : IDateCalculationStrategy
- Inheritance
-
OrdinalDayOfMonthStrategy
- Implements
- Inherited Members
- Extension Methods
Remarks
A positive ordinal counts from the start of the month (1 is the first day); a negative ordinal counts from
the end (-1 is the last day). The result always stays within the specified month: a positive ordinal that
does not exist in a particular year and month produces no occurrence.
// The last day of February (28 or 29 depending on the year).
var strategy = new OrdinalDayOfMonthStrategy(2, -1);
Constructors
OrdinalDayOfMonthStrategy(int, int)
Initializes a new instance of the OrdinalDayOfMonthStrategy class.
public OrdinalDayOfMonthStrategy(int month, int ordinal)
Parameters
Exceptions
- ArgumentOutOfRangeException
monthis not between 1 and 12, orordinalis zero or has an absolute value greater than 31.
Properties
Month
Gets the one-based month.
public int Month { get; }
Property Value
- int
The month.
Ordinal
Gets the signed ordinal position of the day within the month.
public int Ordinal { get; }
Property Value
- int
The ordinal; positive counts from the start, negative from the end.
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 |