WorkingDayInMonthStrategy Class
Definition
- Namespace
- Bodu.Globalization.Calendar.Algorithms
- Assembly
- Bodu.Globalization.Calendar.dll
- Package
- Bodu.Globalization.Calendar 1.0.1
Calculates the Nth working day from the beginning or end of a Gregorian month, such as the first working day of January or the last working day of a reporting month.
public sealed class WorkingDayInMonthStrategy : IDateCalculationStrategy
- Inheritance
-
WorkingDayInMonthStrategy
- Implements
- Inherited Members
- Extension Methods
Remarks
A positive ordinal counts working days from the start of the month (1 is the first working day); a negative
ordinal counts from the end (-1 is the last working day). Working days exclude rest days and applicable
non-working notable-date occurrences, computed deterministically and independently of resource-declaration order by
the StrategyResolutionContext. When the requested ordinal does not exist within the month, no
occurrence is produced rather than spilling into an adjacent month.
// The first working day of January.
var strategy = new WorkingDayInMonthStrategy(1, 1);
Constructors
WorkingDayInMonthStrategy(int, int)
Initializes a new instance of the WorkingDayInMonthStrategy class.
public WorkingDayInMonthStrategy(int month, int ordinal)
Parameters
monthintThe one-based month.
ordinalintThe signed ordinal position of the working day within the month.
Exceptions
- ArgumentOutOfRangeException
monthis not between 1 and 12, orordinalis zero.
Properties
Month
Gets the one-based month.
public int Month { get; }
Property Value
- int
The month.
Ordinal
Gets the signed ordinal position of the working 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 |