Skip to content

Commit

Permalink
Merge pull request #114 from CristiCimpianu/master
Browse files Browse the repository at this point in the history
kue-scheduler next run calculation ignores timezone
  • Loading branch information
lykmapipo committed Feb 19, 2018
2 parents 46d701f + c555743 commit 2beaa2c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
13 changes: 1 addition & 12 deletions index.js
Expand Up @@ -517,20 +517,9 @@ Queue.prototype._computeNextRunTime = function (jobData, done) {
//compute next run from cron interval
cron: function (after) {
try {
//last run of the job is now if not exist
var lastRun =
jobData.lastRun ? new Date(jobData.lastRun) : new Date();

//compute next date from the cron interval
var cronTime = new CronTime(interval, timezone);
var nextRun = cronTime._getNextDateFrom(lastRun);

// Handle cronTime giving back the same date
// for the next run time
if (nextRun.valueOf() === lastRun.valueOf()) {
nextRun =
cronTime._getNextDateFrom(new Date(lastRun.valueOf() + 1000));
}
var nextRun = cronTime.sendAt();

//return computed time
after(null, nextRun.toDate());
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -61,7 +61,7 @@
],
"dependencies": {
"async": "^2.5.0",
"cron": "^1.2.1",
"cron": "^1.3.0",
"date.js": "^0.3.1",
"human-interval": "^0.1.6",
"kue": "^0.11.6",
Expand Down
3 changes: 1 addition & 2 deletions test/capability.spec.js
Expand Up @@ -184,7 +184,6 @@ describe('Queue Scheduling Capabilities', function () {
it('should be able to compute next run from cron interval',
function (done) {
var lastRun = new Date();
lastRun.setSeconds(0);

Queue._computeNextRunTime({
reccurInterval: '* * * * * *',
Expand Down Expand Up @@ -233,4 +232,4 @@ describe('Queue Scheduling Capabilities', function () {
});
});

});
});

0 comments on commit 2beaa2c

Please sign in to comment.