private static bool IsTollFreeDate(DateTime date) { if (date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday) { return(true); } return(HolidayCalculator.IsHoliday(date)); }
private static bool IsDynamicHoliday(DateTime date) { int year = date.Year; DateTime easterDay = HolidayCalculator.EasterDay(year); DateTime maundyThursday = easterDay.AddDays(-3); DateTime goodFriday = easterDay.AddDays(-2); DateTime easterSaturday = easterDay.AddDays(-1); DateTime easterMonday = easterDay.AddDays(1); DateTime ascensionDay = HolidayCalculator.NthConsecutiveWeekDayAfter(6, DayOfWeek.Thursday, easterDay); DateTime pentecostEve = NthConsecutiveWeekDayAfter(7, DayOfWeek.Saturday, easterDay); DateTime pentecostDay = pentecostEve.AddDays(1); DateTime midsummersEve = WeekDayBetween(DayOfWeek.Friday, new DateTime(year, 6, 19), new DateTime(year, 6, 25)); DateTime midsummersDay = midsummersEve.AddDays(1); DateTime allSaintsEve = WeekDayBetween(DayOfWeek.Friday, new DateTime(year, 10, 30), new DateTime(year, 11, 5)); DateTime allSaintsDay = allSaintsEve.AddDays(1); DateTime[] dynamicHolidays = { easterDay, maundyThursday, goodFriday, easterSaturday, easterMonday, ascensionDay, pentecostEve, pentecostDay, midsummersEve, midsummersDay, allSaintsEve, allSaintsDay }; return(dynamicHolidays.Contains(date)); }