Пример #1
0
        public static List <string> ConcatDays(string[] dates)
        {
            var      leavesInterval = new List <string>();
            var      tempDate       = GetDate(dates[0]).AddDays(-1);
            var      lastDate       = GetDate(dates[0]);
            DateTime currentDate    = DateTime.MinValue;
            DateTime nextDay;
            DateTime lastCurrentDate = DateTime.MinValue;

            foreach (string date in dates)
            {
                currentDate = GetDate(date);
                tempDate    = ForwardNonWorkingDays(tempDate);
                nextDay     = tempDate.AddDays(1);
                if (nextDay.Date == currentDate.Date || HollidaysManager.IsHolidayDay(nextDay))
                {
                    tempDate = currentDate;
                }
                else
                {
                    tempDate        = HollidaysManager.IsHolidayDay(tempDate) ? BackwardNonWorkingDays(tempDate) : tempDate;
                    lastCurrentDate = tempDate;
                    leavesInterval.Add(FormatDateInterval(lastDate, tempDate));
                    lastDate = tempDate = currentDate;
                }
            }

            if (currentDate.Date != lastCurrentDate.Date)
            {
                leavesInterval.Add(FormatDateInterval(lastDate, tempDate));
            }
            return(leavesInterval);
        }
Пример #2
0
        private static DateTime BackwardNonWorkingDays(DateTime from)
        {
            var yesturday = from.AddDays(-1);

            return((HollidaysManager.IsHolidayDay(yesturday)) ? BackwardNonWorkingDays(yesturday) : yesturday);
        }
Пример #3
0
        private static DateTime ForwardNonWorkingDays(DateTime from)
        {
            var nextDay = from.AddDays(1);

            return((HollidaysManager.IsHolidayDay(nextDay)) ? ForwardNonWorkingDays(nextDay) : from);
        }