cron 1.7.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/cron.js +10 -2
- package/package.json +1 -1
- package/tests/test-crontime.js +24 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [v1.7.1] - 2019-04-26
|
|
2
|
+
- GH-416 - Fix issue where next execution time is incorrect in some cases in Naoya Inada <naoina@kuune.org> in c08522ff80b3987843e9930c307b76d5fe38b5dc
|
|
3
|
+
|
|
4
|
+
## [v1.7.0] - 2019-03-19
|
|
5
|
+
- GH-408 - DST issue by Shua Talansky <shua@bitbean.com> in 1e971fd6dfa6ba4b0469d99dd64e6c31189d17d3 and 849a2467d16216a9dfa818c57cc26be6b6d0899b
|
|
6
|
+
|
|
1
7
|
## [v1.6.0] - 2018-11-15
|
|
2
8
|
- GH-393, GH-394 - Remove hard limit on max iters in favor of a timeout by Nick Campbell <nicholas.j.campbell@gmail.com> in 57632b0c06c56e82f40b740b8d7986be43842735
|
|
3
9
|
- GH-390 - better handling of real dates which are in the past by Nick Campbell <nicholas.j.campbell@gmail.com> in 7cbcc984aea6ec063e38829f68eb9bc0dfb1c775
|
package/lib/cron.js
CHANGED
|
@@ -260,7 +260,11 @@
|
|
|
260
260
|
|
|
261
261
|
if (
|
|
262
262
|
!(date.date() in this.dayOfMonth) &&
|
|
263
|
-
Object.keys(this.dayOfMonth).length !== 31
|
|
263
|
+
Object.keys(this.dayOfMonth).length !== 31 &&
|
|
264
|
+
!(
|
|
265
|
+
date.day() in this.dayOfWeek &&
|
|
266
|
+
Object.keys(this.dayOfWeek).length !== 7
|
|
267
|
+
)
|
|
264
268
|
) {
|
|
265
269
|
date.add(1, 'd');
|
|
266
270
|
if (date.days() === prevDay) {
|
|
@@ -274,7 +278,11 @@
|
|
|
274
278
|
|
|
275
279
|
if (
|
|
276
280
|
!(date.day() in this.dayOfWeek) &&
|
|
277
|
-
Object.keys(this.dayOfWeek).length !== 7
|
|
281
|
+
Object.keys(this.dayOfWeek).length !== 7 &&
|
|
282
|
+
!(
|
|
283
|
+
date.date() in this.dayOfMonth &&
|
|
284
|
+
Object.keys(this.dayOfMonth).length !== 31
|
|
285
|
+
)
|
|
278
286
|
) {
|
|
279
287
|
date.add(1, 'd');
|
|
280
288
|
if (date.days() === prevDay) {
|
package/package.json
CHANGED
package/tests/test-crontime.js
CHANGED
|
@@ -303,6 +303,30 @@ describe('crontime', function() {
|
|
|
303
303
|
new Date(Date.UTC(2019, 1, 1, 0, 0)).valueOf()
|
|
304
304
|
);
|
|
305
305
|
});
|
|
306
|
+
it('should generate the right next day when cron is set to both day of the month and day of the week (1)', function() {
|
|
307
|
+
var cronTime = new cron.CronTime('0 8 1 * 4');
|
|
308
|
+
var previousDate = new Date(Date.UTC(2019, 3, 22, 0, 0));
|
|
309
|
+
var nextDate = cronTime._getNextDateFrom(previousDate, 'UTC');
|
|
310
|
+
expect(nextDate.valueOf()).to.equal(
|
|
311
|
+
new Date(Date.UTC(2019, 3, 25, 8, 0)).valueOf()
|
|
312
|
+
);
|
|
313
|
+
});
|
|
314
|
+
it('should generate the right next day when cron is set to both day of the month and day of the week (2)', function() {
|
|
315
|
+
var cronTime = new cron.CronTime('0 8 1 * 4');
|
|
316
|
+
var previousDate = new Date(Date.UTC(2019, 3, 26, 0, 0));
|
|
317
|
+
var nextDate = cronTime._getNextDateFrom(previousDate, 'UTC');
|
|
318
|
+
expect(nextDate.valueOf()).to.equal(
|
|
319
|
+
new Date(Date.UTC(2019, 4, 1, 8, 0)).valueOf()
|
|
320
|
+
);
|
|
321
|
+
});
|
|
322
|
+
it('should generate the right next day when cron is set to both day of the month and day of the week (3)', function() {
|
|
323
|
+
var cronTime = new cron.CronTime('0 8 1 * 4');
|
|
324
|
+
var previousDate = new Date(Date.UTC(2019, 7, 1, 7, 59));
|
|
325
|
+
var nextDate = cronTime._getNextDateFrom(previousDate, 'UTC');
|
|
326
|
+
expect(nextDate.valueOf()).to.equal(
|
|
327
|
+
new Date(Date.UTC(2019, 7, 1, 8, 0)).valueOf()
|
|
328
|
+
);
|
|
329
|
+
});
|
|
306
330
|
|
|
307
331
|
it('should accept 0 as a valid UTC offset', function() {
|
|
308
332
|
var clock = sinon.useFakeTimers();
|