RecurrenceHolidays Property

This is used to add holidays to the recurrence holiday list. These will be used in conjunction with the CanOccurOnHoliday option if it is set to false.

Definition

Namespace: EWSoftware.PDI
Assembly: EWSoftware.PDI (in EWSoftware.PDI.dll) Version: 2023.1.2.0
public static HolidayCollection Holidays { get; }

Property Value

HolidayCollection

Remarks

Note that the holiday list is static and will be shared amongst all instances of the Recurrence class to save having to assign it to each new instance.

Example

This example shows one way to add holidays to the recurrence to prevent instances from occurring on them.
C#
// Create a set of fixed and floating holidays.  The recurrence holiday collection
// is static.
Recurrence.Holidays.Clear();

Recurrence.Holidays.AddFixed(1, 1, true, "New Year's Day");
Recurrence.Holidays.AddFloating(DayOccurrence.Third, DayOfWeek.Monday, 1, 0,
    "Martin Luther King Day");
Recurrence.Holidays.AddFloating(DayOccurrence.Third, DayOfWeek.Monday, 2, 0,
    "President's Day");
Recurrence.Holidays.AddFloating(DayOccurrence.Last, DayOfWeek.Monday, 5, 0,
    "Memorial Day");
Recurrence.Holidays.AddFixed(6, 19, true, "Juneteenth").MinimumYear = 2021;
Recurrence.Holidays.AddFixed(7, 4, true, "Independence Day");
Recurrence.Holidays.AddFloating(DayOccurrence.First, DayOfWeek.Monday, 9, 0,
    "Labor Day");
Recurrence.Holidays.AddFixed(11, 11, true, "Veteran's Day");
Recurrence.Holidays.AddFloating(DayOccurrence.Fourth, DayOfWeek.Thursday, 11, 0,
    "Thanksgiving Day");
Recurrence.Holidays.AddFloating(DayOccurrence.Fourth, DayOfWeek.Thursday, 11, 1,
    "Day After Thanksgiving");
Recurrence.Holidays.AddFixed(12, 25, true, "Christmas Day");

// Create a recurrence
Recurrence rRecur = new Recurrence();

// Set it to recur daily but disallow occurrences on any of the defined holidays
rRecur.CanOccurOnHoliday = false;
rRecur.RecurDaily(1);

rRecur.MaximumOccurrences = 365;

DateTimeCollection dc = rRecur.AllInstances();

See Also