Example #1
0
        private static DateTime GetNewWorkDay(DateTime date, HolidayProvider holidays)
        {
            var newDate = GetNewDate(date.AddDays(1), new TimeSpan(8, 0, 0));

            newDate = WorkDayProvider.Validate(newDate, holidays);
            newDate = WorkHourProvider.Validate(newDate, holidays);
            return(holidays.Validate(newDate));
        }
Example #2
0
        private DateTime CheckEndDate(DateTime newStartDate, int minutes, HolidayProvider holidays)
        {
            var endDate = TimeTools.AddMinutes(newStartDate, minutes, holidays);

            endDate = holidays.Validate(endDate);
            endDate = WorkDayProvider.Validate(endDate, holidays);
            endDate = WorkHourProvider.Validate(endDate, holidays);
            return(endDate);
        }
Example #3
0
 private DateTime CheckStartDate(DateTime start, HolidayProvider holidays)
 {
     //Check the start date
     start = holidays.Validate(start);
     //Compensate for Saturday and Sunday
     start = WorkDayProvider.Validate(start, holidays);
     //Ensure only work hours are used
     start = WorkHourProvider.Validate(start, holidays);
     return(start);
 }
Example #4
0
        public static DateTime Validate(DateTime date, HolidayProvider holidays)
        {
            var time = date.TimeOfDay;

            //time is at or before 8AM
            if (time < clockIn)
            {
                return(GetNewDate(date, time, clockIn));
            }
            //time is between 8AM and 12noon
            if (time >= clockIn && time <= clockOut)
            {
                return(date);
            }
            //time is between 12noon and 1pm
            if (time >= clockOut && time <= clockInAfter)
            {
                return(GetNewDate(date, time, clockInAfter));
            }
            //time is between 1pm and 5pm
            if (time >= clockInAfter && time < clockOutAfter)
            {
                return(date);
            }
            //time is 5pm
            if (time == clockOutAfter)
            {
                return(date);
            }
            //time is after 5pm
            if (time >= clockOutAfter)
            {
                date = TimeTools.GetNewDate(date.AddDays(1), clockIn);
                date = WorkDayProvider.Validate(date, holidays);
                date = holidays.Validate(date);
            }
            return(date);
        }