Skip to content
Permalink
Browse files

Allow valid date strings when scheduling (#808)

  • Loading branch information...
wingsbob authored and simison committed Sep 9, 2019
1 parent bedec95 commit 77dcbaddac1e6fc99343d169b4545afc463e4e39
Showing with 7 additions and 1 deletion.
  1. +4 −1 lib/job/schedule.js
  2. +3 −0 test/job.js
@@ -9,6 +9,9 @@ const date = require('date.js');
* @returns {exports} instance of Job
*/
module.exports = function(time) {
this.attrs.nextRunAt = (time instanceof Date) ? time : date(time);
const d = new Date(time);

this.attrs.nextRunAt = Number.isNaN(d.getTime()) ? date(time) : d;

return this;
};
@@ -122,6 +122,9 @@ describe('Job', () => {
it('returns the job', () => {
expect(job.schedule('tomorrow at noon')).to.be(job);
});
it('understands ISODates on the 30th', () => { // https://github.com/agenda/agenda/issues/807
expect(job.schedule('2019-04-30T22:31:00.00Z').attrs.nextRunAt.getTime()).to.equal(1556663460000);
});
});

describe('priority', () => {

0 comments on commit 77dcbad

Please sign in to comment.
You can’t perform that action at this time.