Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions NCrontab.Advanced/CrontabSchedule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,35 +97,36 @@ private DateTime InternalGetNextOccurence(DateTime baseValue, DateTime endValue)
var secondFilters = Filters[CrontabFieldKind.Second].Where(x => x is ITimeFilter).Cast<ITimeFilter>().ToList();
firstSecondValue = secondFilters.Select(x => x.First()).Min();
newSeconds = Increment(secondFilters, newValue.Second, firstSecondValue, out overflow);
newValue = new DateTime(newValue.Year, newValue.Month, newValue.Day, newValue.Hour, newValue.Minute, newSeconds);
newValue = new DateTime(newValue.Year, newValue.Month, newValue.Day, newValue.Hour, newValue.Minute, newSeconds, newValue.Kind);
if (!overflow && !IsMatch(newValue))
{
newSeconds = firstSecondValue;
newValue = new DateTime(newValue.Year, newValue.Month, newValue.Day, newValue.Hour, newValue.Minute, newSeconds);
newValue = new DateTime(newValue.Year, newValue.Month, newValue.Day, newValue.Hour, newValue.Minute, newSeconds, newValue.Kind);
overflow = true;
}
if (!overflow) return MinDate(newValue, endValue);
}

var newMinutes = Increment(minuteFilters, newValue.Minute + (overflow ? 0 : -1), firstMinuteValue, out overflow);
newValue = new DateTime(newValue.Year, newValue.Month, newValue.Day, newValue.Hour, newMinutes, overflow ? firstSecondValue : newSeconds);
newValue = new DateTime(newValue.Year, newValue.Month, newValue.Day, newValue.Hour, newMinutes, overflow ? firstSecondValue : newSeconds, newValue.Kind);
if (!overflow && !IsMatch(newValue))
{
newSeconds = firstSecondValue;
newMinutes = firstMinuteValue;
newValue = new DateTime(newValue.Year, newValue.Month, newValue.Day, newValue.Hour, newMinutes, firstSecondValue);
newValue = new DateTime(newValue.Year, newValue.Month, newValue.Day, newValue.Hour, newMinutes, firstSecondValue, newValue.Kind);
overflow = true;
}
if (!overflow) return MinDate(newValue, endValue);

var newHours = Increment(hourFilters, newValue.Hour + (overflow ? 0 : -1), firstHourValue, out overflow);
newValue = new DateTime(newValue.Year, newValue.Month, newValue.Day, newHours,
overflow ? firstMinuteValue : newMinutes,
overflow ? firstSecondValue : newSeconds);
overflow ? firstSecondValue : newSeconds,
newValue.Kind);

if (!overflow && !IsMatch(newValue))
{
newValue = new DateTime(newValue.Year, newValue.Month, newValue.Day, firstHourValue, firstMinuteValue, firstSecondValue);
newValue = new DateTime(newValue.Year, newValue.Month, newValue.Day, firstHourValue, firstMinuteValue, firstSecondValue, newValue.Kind);
overflow = true;
}

Expand Down