Table of Contents

WorkingDayInMonthStrategy Class

Definition

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

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

month int

The one-based month.

ordinal int

The signed ordinal position of the working day within the month.

Exceptions

ArgumentOutOfRangeException

month is not between 1 and 12, or ordinal is 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

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