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.6.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.0
Choose a head ref
  • 12 commits
  • 9 files changed
  • 2 contributors

Commits on Dec 9, 2018

  1. Added slack notifications for builds.

    Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
    ncb000gt committed Dec 9, 2018
    Copy the full SHA
    4f35a89 View commit details

Commits on Dec 15, 2018

  1. Added a changelog.

    Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
    ncb000gt committed Dec 15, 2018
    Copy the full SHA
    7db4d47 View commit details
  2. Updated packagelock based on version.

    Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
    ncb000gt committed Dec 15, 2018
    Copy the full SHA
    8b6f086 View commit details

Commits on Dec 17, 2018

  1. changelog to md.

    Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
    ncb000gt committed Dec 17, 2018
    Copy the full SHA
    41060fd View commit details
  2. Exception check at the 'seconds' level.

    Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
    ncb000gt committed Dec 17, 2018
    Copy the full SHA
    aaf8d42 View commit details

Commits on Feb 9, 2019

  1. GH-400 - Testing around execution at midnight.

    Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
    ncb000gt committed Feb 9, 2019
    Copy the full SHA
    3773c23 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    660e260 View commit details
  3. Add all tests back in. Update all package dependencies.

    Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
    ncb000gt committed Feb 9, 2019
    Copy the full SHA
    901005b View commit details

Commits on Mar 10, 2019

  1. Update cron.js

    Check if the update to the current hour failed. If it did just add 2 hours. Will fail when you are on the day that starts DST
    shuat authored Mar 10, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1e971fd View commit details
  2. Update cron.js

    keep spacing same as before
    shuat authored Mar 10, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    849a246 View commit details
  3. Merge pull request #410 from shuat/master

    Fix DST Bug by adding 2 hours when 2AM does not exists
    ncb000gt authored Mar 10, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2db8113 View commit details
  4. Version bump to 1.7.0

    Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
    ncb000gt committed Mar 10, 2019
    Copy the full SHA
    d3c5b01 View commit details
Showing with 558 additions and 649 deletions.
  1. +6 −4 .travis.yml
  2. +3 −0 CHANGELOG.md
  3. +3 −0 README.md
  4. +9 −0 examples/at_midnight.js
  5. +10 −2 lib/cron.js
  6. +485 −628 package-lock.json
  7. +13 −13 package.json
  8. +28 −1 tests/test-cron.js
  9. +1 −1 tests/test-crontime.js
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
language: node_js
node_js:
- "4"
- "6"
- "8"
- "10"
- '4'
- '6'
- '8'
- '10'
notifications:
email:
on_success: never
slack:
secure: hHI67BDSUiJQeEiJI/+XJzR/oSsjYPoylhqY10WIZWXfs4TIrdLe513Fzt9BnDNtxpHnCqkgqCb1lF8gNkkOhJKezfDwOZK6HKpNp+zfn7WqBxL0VB3rPw3JoOO9JWoELwV2LyUutbw7m4+OMO45eWgQmQM4mddUMHjyV0awa7A=
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## [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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -108,6 +108,9 @@ Gotchas
granularity for all dates to seconds, but felt that it wasn't a huge problem
so long as you were made aware. If this becomes more of an issue, We can
revisit it.
* Arrow Functions for `onTick`
Arrow functions get their `this` context from their parent scope. Thus, if you use them, you will not get
the `this` context of the cronjob. You can read a little more in this ticket [GH-40](https://github.com/kelektiv/node-cron/issues/47#issuecomment-459762775)


API
9 changes: 9 additions & 0 deletions examples/at_midnight.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const CronJob = require('../lib/cron.js').CronJob;

console.log('Before job instantiation');
const job = new CronJob('00 00 00 * * *', function() {
const d = new Date();
console.log('Midnight:', d);
});
console.log('After job instantiation');
job.start();
12 changes: 10 additions & 2 deletions lib/cron.js
Original file line number Diff line number Diff line change
@@ -143,7 +143,7 @@
}

if (this.realDate) {
const diff = moment().diff(date);
const diff = moment().diff(date, 's');
if (diff > 0) {
throw new Error('WARNING: Date in past. Will never be fired.');
}
@@ -294,9 +294,17 @@
Object.keys(this.hour).length !== 24
) {
origDate = moment(date);
var curHour = date.hours();
date.hours(
date.hours() === 23 && diff > 86400000 ? 0 : date.hours() + 1
date.hours() === 23 && diff > 86400000 ? 0 : date.hours() + 1
);
/*
* Moment Date will not allow you to set the time to 2 AM if there is no 2 AM (on the day we change the clock)
* We will therefore jump to 3AM if time stayed at 1AM
*/
if(curHour === date.hours()){
date.hours(date.hours() + 2);
}
date.minutes(0);
date.seconds(0);
if (date <= origDate) {
Loading