private PubHolidayRules GetSampleRules()
        {
            PubHolidayRules PubHolidayRules = new PubHolidayRules();

            List <SpecialPubHoliday> specialPubHolidays = new List <SpecialPubHoliday>();

            List <MondayPubHoliday> mondayPubHolidays = new List <MondayPubHoliday>();

            List <StaticPubHoliday> staticPubHolidays = new List <StaticPubHoliday>();

            specialPubHolidays.Add(new SpecialPubHoliday {
                Month = 1, Occurrence = 4, WeekDay = DayOfWeek.Sunday
            });

            mondayPubHolidays.Add(new MondayPubHoliday {
                Day = 4, Month = 8
            });

            staticPubHolidays.Add(new StaticPubHoliday {
                Day = 1, Month = 9
            });

            PubHolidayRules = new PubHolidayRules
            {
                MondayPubHolidays            = mondayPubHolidays,
                SpecialDayOfMonthPubHolidays = specialPubHolidays,
                StaticPublicHolidays         = staticPubHolidays
            };

            return(PubHolidayRules);
        }
Exemplo n.º 2
0
 public ActionResult <int> BusinessDaysBetweenTwoDatespublicHolidayRules(DateTime firstDate, DateTime secondDate, PubHolidayRules publicHolidayRules)
 {
     return(_businessDayCounter.BusinessDaysBetweenTwoDates(firstDate, secondDate, publicHolidayRules));
 }
Exemplo n.º 3
0
 public int BusinessDaysBetweenTwoDates(DateTime firstDate, DateTime secondDate, PubHolidayRules publicHolidayRules)
 {
     if (secondDate <= firstDate)
     {
         return(0);
     }
     else
     {
         List <DateTime> dateTimeList = new List <DateTime>();
         dateTimeList.AddRange(PubHolidayHlpr.GetSpecialPubHolidays(publicHolidayRules.SpecialDayOfMonthPubHolidays, firstDate.Year, secondDate.Year));
         dateTimeList.AddRange(PubHolidayHlpr.GetMondayUnchangingPubHolidays(publicHolidayRules.MondayPubHolidays, firstDate.Year, secondDate.Year));
         dateTimeList.AddRange(PubHolidayHlpr.GetUnchangingPubHolidays(publicHolidayRules.StaticPublicHolidays, firstDate.Year, secondDate.Year));
         return(BusinessDaysBetweenTwoDates(firstDate, secondDate, dateTimeList));
     }
 }