Beispiel #1
0
        //creates the holidays for a year
        public static void CreateHolidays(int startYear)
        {
            HolidayYear.Clear();

            int endYear = startYear + 5;

            for (int i = startYear; i < endYear; i++)
            {
                foreach (Holiday holiday in Holidays.GetHolidays())
                {
                    if (holiday.Type == Holiday.HolidayType.Fixed_Date)
                    {
                        HolidayYear.AddHoliday(new HolidayYearEvent(new DateTime(startYear, holiday.Date.Month, holiday.Date.Day), holiday, 1));
                    }
                    if (holiday.Type == Holiday.HolidayType.Fixed_Month)
                    {
                        HolidayYearEvent eHoliday = new HolidayYearEvent(new DateTime(startYear, holiday.Month, 1), holiday, DateTime.DaysInMonth(startYear, holiday.Month));
                        HolidayYear.AddHoliday(eHoliday);
                    }
                    if (holiday.Type == Holiday.HolidayType.Fixed_Week)
                    {
                        HolidayYear.AddHoliday(new HolidayYearEvent(MathHelpers.GetFirstDateOfWeek(startYear, holiday.Week), holiday, 7));
                    }
                    if (holiday.Type == Holiday.HolidayType.Non_Fixed_Date)
                    {
                        HolidayYear.AddHoliday(new HolidayYearEvent(MathHelpers.GetNthWeekdayOfMonth(startYear, holiday.Month, holiday.Day, holiday.Week), holiday, 1));
                    }
                }
            }
        }