cron-parser
Advanced tools
Comparing version 2.12.0 to 2.13.0
@@ -5,3 +5,3 @@ { | ||
"description": "Node.js library for parsing crontab instructions", | ||
"version": "2.12.0", | ||
"version": "2.13.0", | ||
"keywords": ["cron", "crontab", "parser"], | ||
@@ -11,3 +11,3 @@ "dependencies": {}, | ||
"main": "lib/parser.js", | ||
"scripts": [ "lib/parser.js", "lib/expression.js", "lib/date.js" ] | ||
"scripts": ["lib/parser.js", "lib/expression.js", "lib/date.js"] | ||
} |
@@ -422,5 +422,5 @@ 'use strict'; | ||
* desired day of week. | ||
* | ||
* @param {CronDate} date | ||
* @param {Number} nthDayOfWeek | ||
* | ||
* @param {CronDate} date | ||
* @param {Number} nthDayOfWeek | ||
* @return {Boolean} | ||
@@ -719,4 +719,4 @@ * @private | ||
*/ | ||
CronExpression.prototype.reset = function reset () { | ||
this._currentDate = new CronDate(this._options.currentDate); | ||
CronExpression.prototype.reset = function reset (newDate) { | ||
this._currentDate = new CronDate(newDate || this._options.currentDate); | ||
}; | ||
@@ -807,4 +807,4 @@ | ||
* Parses out the # special character for the dayOfWeek field & adds it to options. | ||
* | ||
* @param {String} val | ||
* | ||
* @param {String} val | ||
* @return {String} | ||
@@ -832,3 +832,3 @@ * @private | ||
} | ||
options.nthDayOfWeek = nthValue; | ||
@@ -835,0 +835,0 @@ return atoms[0]; |
@@ -78,3 +78,3 @@ export = CronParser | ||
/** Reset expression iterator state */ | ||
reset(): void | ||
reset(resetDate?: string | number | Date): void | ||
@@ -81,0 +81,0 @@ /** Parse input expression (async) */ |
{ | ||
"name": "cron-parser", | ||
"version": "2.12.0", | ||
"version": "2.13.0", | ||
"description": "Node.js library for parsing crontab instructions", | ||
@@ -5,0 +5,0 @@ "main": "lib/parser.js", |
@@ -454,2 +454,50 @@ var test = require('tap').test; | ||
test('reset to given date', function(t){ | ||
try { | ||
var options = { | ||
currentDate: new CronDate('Wed, 26 Dec 2012 14:38:53') | ||
}; | ||
var interval = CronExpression.parse('*/20 * * * *', options); | ||
t.ok(interval, 'Interval parsed'); | ||
// Forward iteration | ||
var next = interval.next(); | ||
t.equal(next.getHours(), 14, 'Hour matches'); | ||
t.equal(next.getMinutes(), 40, 'Minute matches'); | ||
interval.reset(); // defaults to initial currentDate | ||
next = interval.next(); | ||
t.equal(next.getHours(), 14, 'Hour matches'); | ||
t.equal(next.getMinutes(), 40, 'Minute matches'); | ||
interval.reset(new CronDate('Wed, 26 Dec 2012 17:23:53')); | ||
next = interval.next(); | ||
t.equal(next.getHours(), 17, 'Hour matches'); | ||
t.equal(next.getMinutes(), 40, 'Minute matches'); | ||
next = interval.next(); | ||
t.equal(next.getHours(), 18, 'Hour matches'); | ||
t.equal(next.getMinutes(), 0, 'Minute matches'); | ||
interval.reset(new Date('2019-06-18T08:18:36.000')); | ||
next = interval.prev(); | ||
t.equal(next.getDate(), 18, 'Date matches'); | ||
t.equal(next.getHours(), 8, 'Hour matches'); | ||
t.equal(next.getMinutes(), 0, 'Minute matches'); | ||
next = interval.prev(); | ||
t.equal(next.getDate(), 18, 'Date matches'); | ||
t.equal(next.getHours(), 7, 'Hour matches'); | ||
t.equal(next.getMinutes(), 40, 'Minute matches'); | ||
t.end(); | ||
} catch (err) { | ||
t.ifError(err, 'Reset error'); | ||
} | ||
}); | ||
test('parse expression as UTC', function(t) { | ||
@@ -614,3 +662,3 @@ try { | ||
}); | ||
var firstExpectedDates = [ | ||
@@ -1105,4 +1153,4 @@ new CronDate('2019-06-01T12:00:00.000'), | ||
t.equal( | ||
date.toISOString(), | ||
expected.toISOString(), | ||
date.toISOString(), | ||
expected.toISOString(), | ||
'Expression "' + expression + '" has next() that matches expected: ' + expected.toISOString() | ||
@@ -1117,4 +1165,4 @@ ); | ||
t.equal( | ||
date.toISOString(), | ||
expected.toISOString(), | ||
date.toISOString(), | ||
expected.toISOString(), | ||
'Expression "' + expression + '" has prev() that matches expected: ' + expected.toISOString() | ||
@@ -1147,4 +1195,4 @@ ); | ||
t.equal( | ||
date.toISOString(), | ||
expected.toISOString(), | ||
date.toISOString(), | ||
expected.toISOString(), | ||
'Expression "0 0 0 ? MAY 0#2" has next() that matches expected: ' + expected.toISOString() | ||
@@ -1159,4 +1207,4 @@ ); | ||
t.equal( | ||
date.toISOString(), | ||
expected.toISOString(), | ||
date.toISOString(), | ||
expected.toISOString(), | ||
'Expression "0 0 0 ? MAY 0#2" has prev() that matches expected: ' + expected.toISOString() | ||
@@ -1183,4 +1231,4 @@ ); | ||
t.equal( | ||
date.toISOString(), | ||
expected.toISOString(), | ||
date.toISOString(), | ||
expected.toISOString(), | ||
'Expression "0 0 12 ? MAY 0#2" has next() that matches expected: ' + expected.toISOString() | ||
@@ -1206,4 +1254,4 @@ ); | ||
t.equal( | ||
date.toISOString(), | ||
expected.toISOString(), | ||
date.toISOString(), | ||
expected.toISOString(), | ||
'Expression "0 0 12 ? MAY 0#2" has next() that matches expected: ' + expected.toISOString() | ||
@@ -1223,3 +1271,3 @@ ); | ||
}; | ||
var expectedDates = [ | ||
@@ -1239,4 +1287,4 @@ new CronDate('2019-04-16'), | ||
t.equal( | ||
date.toISOString(), | ||
expected.toISOString(), | ||
date.toISOString(), | ||
expected.toISOString(), | ||
'Expression "0 0 0 16,18 * 3#3" has next() that matches expected: ' + expected.toISOString() | ||
@@ -1251,4 +1299,4 @@ ); | ||
t.equal( | ||
date.toISOString(), | ||
expected.toISOString(), | ||
date.toISOString(), | ||
expected.toISOString(), | ||
'Expression "0 0 0 16,18 * 3#3" has prev() that matches expected: ' + expected.toISOString() | ||
@@ -1276,3 +1324,3 @@ ); | ||
}); | ||
t.end(); | ||
@@ -1287,3 +1335,3 @@ }); | ||
}, new Error('Constraint error, invalid dayOfWeek `#` and `-` special characters are incompatible')); | ||
t.end(); | ||
@@ -1297,3 +1345,3 @@ }); | ||
}, new Error('Constraint error, invalid dayOfWeek `#` and `/` special characters are incompatible')); | ||
t.end(); | ||
@@ -1307,5 +1355,5 @@ }); | ||
}, new Error('Constraint error, invalid dayOfWeek `#` and `,` special characters are incompatible')); | ||
t.end(); | ||
}); | ||
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91834
18
2558