Table of Contents

IsoWeekDateStrategy Class

Definition

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

Calculates a weekday within an ISO-8601 week of an ISO week-year, such as the Monday of ISO week 1 or the Friday of ISO week 20.

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

Remarks

The year supplied to Calculate(int, StrategyResolutionContext) is interpreted as the ISO week-year, so a valid result can fall in the previous or following Gregorian calendar year. ISO week 53 is valid only for ISO years that contain 53 weeks; a week-53 request for a 52-week year produces no occurrence.

// The Monday of ISO week 1.
var strategy = new IsoWeekDateStrategy(1, DayOfWeek.Monday);

Constructors

IsoWeekDateStrategy(int, DayOfWeek)

Initializes a new instance of the IsoWeekDateStrategy class.

public IsoWeekDateStrategy(int week, DayOfWeek dayOfWeek)

Parameters

week int

The one-based ISO-8601 week number.

dayOfWeek DayOfWeek

The weekday within the ISO week.

Exceptions

ArgumentOutOfRangeException

week is not between 1 and 53, or dayOfWeek is not a defined DayOfWeek.

Properties

DayOfWeek

Gets the weekday within the ISO week.

public DayOfWeek DayOfWeek { get; }

Property Value

DayOfWeek

The target weekday.

Week

Gets the one-based ISO-8601 week number.

public int Week { get; }

Property Value

int

The ISO week.

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