WeekdayNearRuleStrategy Class
Definition
- Namespace
- Bodu.Globalization.Calendar.Algorithms
- Assembly
- Bodu.Globalization.Calendar.dll
- Package
- Bodu.Globalization.Calendar 1.0.1
Calculates a weekday on, before, after, or nearest to the date produced by another rule, such as the first Monday after Easter Sunday.
public sealed class WeekdayNearRuleStrategy : IDateCalculationStrategy
- Inheritance
-
WeekdayNearRuleStrategy
- Implements
- Inherited Members
- Extension Methods
Remarks
This is the dynamic-reference counterpart to WeekdayNearDateStrategy: the anchor is another rule's
occurrence rather than a fixed month and day. The referenced rule is resolved for year + referenceYearOffset,
letting a rule in one civil year anchor to a reference in an adjacent year. A missing, ambiguous, circular, or
recurring reference produces no occurrence and is reported by semantic validation where statically detectable.
// The first Monday after Easter Sunday.
var strategy = new WeekdayNearRuleStrategy("easter-sunday", null, DayOfWeek.Monday, WeekdayProximity.After);
Constructors
WeekdayNearRuleStrategy(string, string?, DayOfWeek, WeekdayProximity, int)
Initializes a new instance of the WeekdayNearRuleStrategy class.
public WeekdayNearRuleStrategy(string notableDateRef, string? ruleRef, DayOfWeek dayOfWeek, WeekdayProximity direction, int referenceYearOffset = 0)
Parameters
notableDateRefstringThe identifier of the referenced notable-date concept.
ruleRefstringThe identifier of the referenced rule, or null to use its sole rule.
dayOfWeekDayOfWeekThe weekday to seek.
directionWeekdayProximityThe direction and inclusivity to apply when seeking the weekday.
referenceYearOffsetintThe signed year offset applied to the referenced rule.
Exceptions
- ArgumentNullException
notableDateRefis null.- ArgumentOutOfRangeException
dayOfWeekordirectionis not a defined enumeration value.
Properties
DayOfWeek
Gets the weekday to seek.
public DayOfWeek DayOfWeek { get; }
Property Value
- DayOfWeek
The target weekday.
Direction
Gets the direction and inclusivity applied when seeking the weekday.
public WeekdayProximity Direction { get; }
Property Value
- WeekdayProximity
The configured WeekdayProximity.
NotableDateRef
Gets the identifier of the referenced notable-date concept.
public string NotableDateRef { get; }
Property Value
- string
The referenced concept id.
ReferenceYearOffset
Gets the signed year offset applied to the referenced rule.
public int ReferenceYearOffset { get; }
Property Value
- int
The reference year offset.
RuleRef
Gets the identifier of the referenced rule.
public string? RuleRef { get; }
Property Value
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 |