Skip to content

Commit

Permalink
Merge pull request #14 from gerrod/master
Browse files Browse the repository at this point in the history
Correctly roll over from 58 to 59 minutes/seconds
  • Loading branch information
jcoutch authored Oct 25, 2018
2 parents d46fa1f + 42e97a3 commit b569ac9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions NCrontab.Advanced.Tests/CronInstanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ public void Evaluations()
new { startTime = "01/01/2003 00:00:00", inputString = "* * * * *", nextOccurence = "01/01/2003 00:01:00", cronStringFormat = CronStringFormat.Default },
new { startTime = "01/01/2003 00:01:00", inputString = "* * * * *", nextOccurence = "01/01/2003 00:02:00", cronStringFormat = CronStringFormat.Default },
new { startTime = "01/01/2003 00:02:00", inputString = "* * * * *", nextOccurence = "01/01/2003 00:03:00", cronStringFormat = CronStringFormat.Default },
new { startTime = "01/01/2003 00:58:00", inputString = "* * * * *", nextOccurence = "01/01/2003 00:59:00", cronStringFormat = CronStringFormat.Default },
new { startTime = "01/01/2003 01:58:00", inputString = "* * * * *", nextOccurence = "01/01/2003 01:59:00", cronStringFormat = CronStringFormat.Default },
new { startTime = "01/01/2003 00:59:00", inputString = "* * * * *", nextOccurence = "01/01/2003 01:00:00", cronStringFormat = CronStringFormat.Default },
new { startTime = "01/01/2003 01:59:00", inputString = "* * * * *", nextOccurence = "01/01/2003 02:00:00", cronStringFormat = CronStringFormat.Default },
new { startTime = "01/01/2003 23:59:00", inputString = "* * * * *", nextOccurence = "02/01/2003 00:00:00", cronStringFormat = CronStringFormat.Default },
Expand All @@ -170,6 +172,8 @@ public void Evaluations()
new { startTime = "01/01/2003 00:00:00", inputString = "* * * * * *", nextOccurence = "01/01/2003 00:00:01", cronStringFormat = CronStringFormat.WithSeconds },
new { startTime = "01/01/2003 00:00:01", inputString = "* * * * * *", nextOccurence = "01/01/2003 00:00:02", cronStringFormat = CronStringFormat.WithSeconds },
new { startTime = "01/01/2003 00:00:02", inputString = "* * * * * *", nextOccurence = "01/01/2003 00:00:03", cronStringFormat = CronStringFormat.WithSeconds },
new { startTime = "01/01/2003 00:00:58", inputString = "* * * * * *", nextOccurence = "01/01/2003 00:00:59", cronStringFormat = CronStringFormat.WithSeconds },
new { startTime = "01/01/2003 00:01:58", inputString = "* * * * * *", nextOccurence = "01/01/2003 00:01:59", cronStringFormat = CronStringFormat.WithSeconds },
new { startTime = "01/01/2003 00:00:59", inputString = "* * * * * *", nextOccurence = "01/01/2003 00:01:00", cronStringFormat = CronStringFormat.WithSeconds },
new { startTime = "01/01/2003 00:01:59", inputString = "* * * * * *", nextOccurence = "01/01/2003 00:02:00", cronStringFormat = CronStringFormat.WithSeconds },
new { startTime = "01/01/2003 23:59:59", inputString = "* * * * * *", nextOccurence = "02/01/2003 00:00:00", cronStringFormat = CronStringFormat.WithSeconds },
Expand All @@ -180,6 +184,8 @@ public void Evaluations()
new { startTime = "01/01/2003 00:00:00", inputString = "* * * * * *", nextOccurence = "01/01/2003 00:01:00", cronStringFormat = CronStringFormat.WithYears },
new { startTime = "01/01/2003 00:01:00", inputString = "* * * * * *", nextOccurence = "01/01/2003 00:02:00", cronStringFormat = CronStringFormat.WithYears },
new { startTime = "01/01/2003 00:02:00", inputString = "* * * * * *", nextOccurence = "01/01/2003 00:03:00", cronStringFormat = CronStringFormat.WithYears },
new { startTime = "01/01/2003 00:58:00", inputString = "* * * * * *", nextOccurence = "01/01/2003 00:59:00", cronStringFormat = CronStringFormat.WithYears },
new { startTime = "01/01/2003 01:58:00", inputString = "* * * * * *", nextOccurence = "01/01/2003 01:59:00", cronStringFormat = CronStringFormat.WithYears },
new { startTime = "01/01/2003 00:59:00", inputString = "* * * * * *", nextOccurence = "01/01/2003 01:00:00", cronStringFormat = CronStringFormat.WithYears },
new { startTime = "01/01/2003 01:59:00", inputString = "* * * * * *", nextOccurence = "01/01/2003 02:00:00", cronStringFormat = CronStringFormat.WithYears },
new { startTime = "01/01/2003 23:59:00", inputString = "* * * * * *", nextOccurence = "02/01/2003 00:00:00", cronStringFormat = CronStringFormat.WithYears },
Expand All @@ -190,6 +196,8 @@ public void Evaluations()
new { startTime = "01/01/2003 00:00:00", inputString = "* * * * * * *", nextOccurence = "01/01/2003 00:00:01", cronStringFormat = CronStringFormat.WithSecondsAndYears },
new { startTime = "01/01/2003 00:00:01", inputString = "* * * * * * *", nextOccurence = "01/01/2003 00:00:02", cronStringFormat = CronStringFormat.WithSecondsAndYears },
new { startTime = "01/01/2003 00:00:02", inputString = "* * * * * * *", nextOccurence = "01/01/2003 00:00:03", cronStringFormat = CronStringFormat.WithSecondsAndYears },
new { startTime = "01/01/2003 00:00:58", inputString = "* * * * * * *", nextOccurence = "01/01/2003 00:00:59", cronStringFormat = CronStringFormat.WithSecondsAndYears },
new { startTime = "01/01/2003 00:01:58", inputString = "* * * * * * *", nextOccurence = "01/01/2003 00:01:59", cronStringFormat = CronStringFormat.WithSecondsAndYears },
new { startTime = "01/01/2003 00:00:59", inputString = "* * * * * * *", nextOccurence = "01/01/2003 00:01:00", cronStringFormat = CronStringFormat.WithSecondsAndYears },
new { startTime = "01/01/2003 00:01:59", inputString = "* * * * * * *", nextOccurence = "01/01/2003 00:02:00", cronStringFormat = CronStringFormat.WithSecondsAndYears },
new { startTime = "01/01/2003 23:59:59", inputString = "* * * * * * *", nextOccurence = "02/01/2003 00:00:00", cronStringFormat = CronStringFormat.WithSecondsAndYears },
Expand Down
2 changes: 1 addition & 1 deletion NCrontab.Advanced/Filters/AnyFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public bool IsMatch(DateTime value)
throw new CrontabException("Cannot call Next for Day, Month or DayOfWeek types");

var newValue = (int?) value + 1;
if (newValue >= max) newValue = null;
if (newValue > max) newValue = null;

return newValue;
}
Expand Down

0 comments on commit b569ac9

Please sign in to comment.