Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: kelektiv/node-cron
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.7.0
Choose a base ref
...
head repository: kelektiv/node-cron
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.7.1
Choose a head ref
  • 3 commits
  • 5 files changed
  • 2 contributors

Commits on Apr 22, 2019

  1. Verified

    This commit was signed with the committer’s verified signature.
    naoina Naoya Inada
    Copy the full SHA
    c08522f View commit details

Commits on Apr 23, 2019

  1. Merge pull request #418 from naoina/master

    Fix the issue where next execution time is incorrect in some cases
    ncb000gt authored Apr 23, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    825696a View commit details

Commits on Apr 27, 2019

  1. Version bump with changelog.

    Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
    ncb000gt committed Apr 27, 2019
    Copy the full SHA
    96060bb View commit details
Showing with 42 additions and 4 deletions.
  1. +6 −0 CHANGELOG.md
  2. +10 −2 lib/cron.js
  3. +1 −1 package-lock.json
  4. +1 −1 package.json
  5. +24 −0 tests/test-crontime.js
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [v1.7.1] - 2019-04-26
- GH-416 - Fix issue where next execution time is incorrect in some cases in Naoya Inada <naoina@kuune.org> in c08522ff80b3987843e9930c307b76d5fe38b5dc

## [v1.7.0] - 2019-03-19
- GH-408 - DST issue by Shua Talansky <shua@bitbean.com> in 1e971fd6dfa6ba4b0469d99dd64e6c31189d17d3 and 849a2467d16216a9dfa818c57cc26be6b6d0899b

## [v1.6.0] - 2018-11-15
- 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
- GH-390 - better handling of real dates which are in the past by Nick Campbell <nicholas.j.campbell@gmail.com> in 7cbcc984aea6ec063e38829f68eb9bc0dfb1c775
12 changes: 10 additions & 2 deletions lib/cron.js
Original file line number Diff line number Diff line change
@@ -260,7 +260,11 @@

if (
!(date.date() in this.dayOfMonth) &&
Object.keys(this.dayOfMonth).length !== 31
Object.keys(this.dayOfMonth).length !== 31 &&
!(
date.day() in this.dayOfWeek &&
Object.keys(this.dayOfWeek).length !== 7
)
) {
date.add(1, 'd');
if (date.days() === prevDay) {
@@ -274,7 +278,11 @@

if (
!(date.day() in this.dayOfWeek) &&
Object.keys(this.dayOfWeek).length !== 7
Object.keys(this.dayOfWeek).length !== 7 &&
!(
date.date() in this.dayOfMonth &&
Object.keys(this.dayOfMonth).length !== 31
)
) {
date.add(1, 'd');
if (date.days() === prevDay) {
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cron",
"description": "Cron jobs for your node",
"version": "1.7.0",
"version": "1.7.1",
"author": "Nick Campbell <nicholas.j.campbell@gmail.com> (http://github.com/ncb000gt)",
"bugs": {
"url": "http://github.com/kelektiv/node-cron/issues"
24 changes: 24 additions & 0 deletions tests/test-crontime.js
Original file line number Diff line number Diff line change
@@ -303,6 +303,30 @@ describe('crontime', function() {
new Date(Date.UTC(2019, 1, 1, 0, 0)).valueOf()
);
});
it('should generate the right next day when cron is set to both day of the month and day of the week (1)', function() {
var cronTime = new cron.CronTime('0 8 1 * 4');
var previousDate = new Date(Date.UTC(2019, 3, 22, 0, 0));
var nextDate = cronTime._getNextDateFrom(previousDate, 'UTC');
expect(nextDate.valueOf()).to.equal(
new Date(Date.UTC(2019, 3, 25, 8, 0)).valueOf()
);
});
it('should generate the right next day when cron is set to both day of the month and day of the week (2)', function() {
var cronTime = new cron.CronTime('0 8 1 * 4');
var previousDate = new Date(Date.UTC(2019, 3, 26, 0, 0));
var nextDate = cronTime._getNextDateFrom(previousDate, 'UTC');
expect(nextDate.valueOf()).to.equal(
new Date(Date.UTC(2019, 4, 1, 8, 0)).valueOf()
);
});
it('should generate the right next day when cron is set to both day of the month and day of the week (3)', function() {
var cronTime = new cron.CronTime('0 8 1 * 4');
var previousDate = new Date(Date.UTC(2019, 7, 1, 7, 59));
var nextDate = cronTime._getNextDateFrom(previousDate, 'UTC');
expect(nextDate.valueOf()).to.equal(
new Date(Date.UTC(2019, 7, 1, 8, 0)).valueOf()
);
});

it('should accept 0 as a valid UTC offset', function() {
var clock = sinon.useFakeTimers();