Beispiel #1
0
        /// <summary>
        /// Discovery day (Third monday in August)
        /// </summary>
        /// <param name="year"></param>
        /// <returns></returns>
        public static DateTime DiscoveryDay(int year)
        {
            var hol = new DateTime(year, 8, 1);

            hol = HolidayCalculator.FindOccurrenceOfDayOfWeek(hol, DayOfWeek.Monday, 3);
            return(hol);
        }
        /// <summary>
        /// Thanksgiving - Fourth Thursday in November
        /// </summary>
        /// <param name="year">The year.</param>
        /// <returns></returns>
        public static Holiday Thanksgiving(int year)
        {
            var hol = new DateTime(year, 11, 22);

            hol = HolidayCalculator.FindOccurrenceOfDayOfWeek(hol, DayOfWeek.Thursday, 1);
            return(new Holiday(hol, hol));
        }
Beispiel #3
0
        /// <summary>
        /// Gold Cup Parade day (Third friday in August)
        /// </summary>
        /// <param name="year"></param>
        /// <returns></returns>
        public static DateTime GoldCupParadeDay(int year)
        {
            var hol = new DateTime(year, 8, 1);

            hol = HolidayCalculator.FindOccurrenceOfDayOfWeek(hol, DayOfWeek.Friday, 3);
            return(hol);
        }
Beispiel #4
0
        /// <summary>
        /// Family day (3rd monday of February) (2nd monday for BC)
        /// </summary>
        /// <param name="year"></param>
        /// <param name="province"></param>
        /// <returns></returns>
        public static DateTime FamilyDay(int year, string province = null)
        {
            var hol = new DateTime(year, 2, 1);

            if (province == "BC")
            {
                hol = HolidayCalculator.FindOccurrenceOfDayOfWeek(hol, DayOfWeek.Monday, 2);
            }
            else
            {
                hol = HolidayCalculator.FindOccurrenceOfDayOfWeek(hol, DayOfWeek.Monday, 3);
            }

            return(hol);
        }
        /// <summary>
        /// Family day (3rd monday of February) (2nd monday for BC)
        /// </summary>
        /// <param name="year"></param>
        /// <param name="province"></param>
        /// <returns></returns>
        public static DateTime FamilyDay(int year, string province = null)
        {
            var hol = new DateTime(year, 2, 1);

            //Starting in 2019, the B.C. Family Day holiday will be on the third Monday of February, moving it in line with other provinces in Canada.
            //#32 thanks @ericyang97
            if (province == "BC" && year < 2019)
            {
                hol = HolidayCalculator.FindOccurrenceOfDayOfWeek(hol, DayOfWeek.Monday, 2);
            }
            else
            {
                hol = HolidayCalculator.FindOccurrenceOfDayOfWeek(hol, DayOfWeek.Monday, 3);
            }

            return(hol);
        }