Ejemplo n.º 1
0
        public DateTime GetNextValid(DateTime when)
        {
            var workingValue = new DateTime(when.Year, when.Month, when.Day, when.Hour, when.Minute, 0);

            workingValue = workingValue.AddMinutes(1);
            bool processDayOfWeek  = !(DayOfWeekSection is IgnoreExpressionSection);
            bool processDayOfMonth = !processDayOfWeek && !(DayOfMonthSection is IgnoreExpressionSection);

            while (!IsMatch(workingValue))
            {
                if (MinuteSection.Next(ref workingValue))
                {
                    if (HourSection.Next(ref workingValue))
                    {
                        if (processDayOfWeek && DayOfWeekSection.Next(ref workingValue))
                        {
                            MonthSection.Next(ref workingValue);
                            DayOfWeekSection.First(ref workingValue);
                        }
                        else if (processDayOfMonth && DayOfMonthSection.Next(ref workingValue))
                        {
                            MonthSection.Next(ref workingValue);
                            DayOfMonthSection.First(ref workingValue);
                        }
                        HourSection.First(ref workingValue);
                    }
                    MinuteSection.First(ref workingValue);
                }
            }
            return(workingValue);
        }
Ejemplo n.º 2
0
 public bool IsMatch(DateTime when)
 {
     return(MinuteSection.IsMatch(when) &&
            HourSection.IsMatch(when) &&
            DayOfMonthSection.IsMatch(when) &&
            DayOfWeekSection.IsMatch(when) &&
            MonthSection.IsMatch(when));
 }