RecurrenceCanOccurOnHoliday Property

This is used to set or get whether or not the instances can occur on a holiday

Definition

Namespace: EWSoftware.PDI
Assembly: EWSoftware.PDI (in EWSoftware.PDI.dll) Version: 2023.1.2.0
public bool CanOccurOnHoliday { get; set; }

Property Value

Boolean

Remarks

If set to false, any generated instance that matches a holiday date found in the Holidays property will be discarded. The default is true so that instances can occur on holiday dates.

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