WorkingDayOffsetFromRuleStrategy Class
Definition
- Namespace
- Bodu.Globalization.Calendar.Algorithms
- Assembly
- Bodu.Globalization.Calendar.dll
- Package
- Bodu.Globalization.Calendar 1.0.1
Calculates a date a specified number of working days before or after another rule's occurrence, such as the last working day before a public-holiday shutdown.
public sealed class WorkingDayOffsetFromRuleStrategy : IDateCalculationStrategy
- Inheritance
-
WorkingDayOffsetFromRuleStrategy
- Implements
- Inherited Members
- Extension Methods
Remarks
Unlike OffsetFromRuleStrategy, which counts calendar days, this strategy counts working days: the
reference date is the origin and is not counted, and non-working days (rest days and applicable non-working
notable-date occurrences) are skipped. The working-day set is computed deterministically and independently of
resource-declaration order by the StrategyResolutionContext. The referenced rule is resolved for
year + referenceYearOffset.
// The last working day before Boxing Day.
var strategy = new WorkingDayOffsetFromRuleStrategy("boxing-day", null, -1);
Constructors
WorkingDayOffsetFromRuleStrategy(string, string?, int, int)
Initializes a new instance of the WorkingDayOffsetFromRuleStrategy class.
public WorkingDayOffsetFromRuleStrategy(string notableDateRef, string? ruleRef, int offsetWorkingDays, 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.
offsetWorkingDaysintThe signed number of working days to move from the referenced occurrence.
referenceYearOffsetintThe signed year offset applied to the referenced rule.
Exceptions
- ArgumentNullException
notableDateRefis null.
Properties
NotableDateRef
Gets the identifier of the referenced notable-date concept.
public string NotableDateRef { get; }
Property Value
- string
The referenced concept id.
OffsetWorkingDays
Gets the signed number of working days to move from the referenced occurrence.
public int OffsetWorkingDays { get; }
Property Value
- int
The working-day offset.
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 |