Skip to content

Commit abce185

Browse files
committed
Bug fix for N/1 ignoring remaining field values; closes #16
1 parent a6e6429 commit abce185

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

NCrontab.Tests/CrontabScheduleTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ public void Formatting(string format, string expression, bool includingSeconds)
253253
[TestCase("28/02/2003 12:01:00", "1 12 28 2 *", "28/02/2004 12:01:00", false)]
254254
[TestCase("29/02/2004 12:01:00", "1 12 28 2 *", "28/02/2005 12:01:00", false)]
255255

256+
[TestCase("01/01/2000 12:00:00", "40 14/1 * * *", "01/01/2000 14:40:00", false)]
257+
[TestCase("01/01/2000 14:40:00", "40 14/1 * * *", "01/01/2000 15:40:00", false)]
258+
256259
public void Evaluations(string startTimeString, string cronExpression, string nextTimeString, bool includingSeconds)
257260
{
258261
CronCall(startTimeString, cronExpression, nextTimeString, new ParseOptions

NCrontab/AssemblyInfo.g.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// This code was generated by a tool. Any changes made manually will be lost
22
// the next time this code is regenerated.
3-
// Generated: Fri, 11 Dec 2015 07:45:17 GMT
4-
3+
// Generated: Thu, 20 Oct 2016 06:08:37 GMT
4+
55
using System.Reflection;
6-
7-
[assembly: AssemblyVersion("3.1.19111.0")]
8-
[assembly: AssemblyFileVersion("3.1.19111.745")]
6+
7+
[assembly: AssemblyVersion("3.1.20120.0")]
8+
[assembly: AssemblyFileVersion("3.1.20120.608")]

NCrontab/CrontabFieldImpl.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ T InternalParse<T>(string str, CrontabFieldAccumulator<T> acc, T success, Func<E
220220
return result;
221221
}
222222

223-
var every = 1;
223+
int? every = null;
224224

225225
//
226226
// Look for stepping first (e.g. */2 = every 2nd).
@@ -240,7 +240,7 @@ T InternalParse<T>(string str, CrontabFieldAccumulator<T> acc, T success, Func<E
240240

241241
if (str.Length == 1 && str[0]== '*')
242242
{
243-
return acc(-1, -1, every, success, errorSelector);
243+
return acc(-1, -1, every ?? 1, success, errorSelector);
244244
}
245245

246246
//
@@ -254,7 +254,7 @@ T InternalParse<T>(string str, CrontabFieldAccumulator<T> acc, T success, Func<E
254254
var first = ParseValue(str.Substring(0, dashIndex));
255255
var last = ParseValue(str.Substring(dashIndex + 1));
256256

257-
return acc(first, last, every, success, errorSelector);
257+
return acc(first, last, every ?? 1, success, errorSelector);
258258
}
259259

260260
//
@@ -263,11 +263,11 @@ T InternalParse<T>(string str, CrontabFieldAccumulator<T> acc, T success, Func<E
263263

264264
var value = ParseValue(str);
265265

266-
if (every == 1)
266+
if (every == null)
267267
return acc(value, value, 1, success, errorSelector);
268268

269269
Debug.Assert(every != 0);
270-
return acc(value, MaxValue, every, success, errorSelector);
270+
return acc(value, MaxValue, every.Value, success, errorSelector);
271271
}
272272

273273
int ParseValue(string str)

0 commit comments

Comments
 (0)