cron-parser icon indicating copy to clipboard operation
cron-parser copied to clipboard

cron-parser does not accept currentDate timestamp of 0

Open sbruinsje opened this issue 1 year ago • 0 comments

Since version 3.0.0 of cron-parser it is not possible anymore to pass a currentDate timestamp of 0. It will be ignored and will instead use the current local time/date:

This will give a timestamp close to the local system time instead of the 60000 as I would expect:

const CronParser = require('cron-parser');
let iterator = CronParser.parseExpression('0 * * * * *', { currentDate: 0, tz: 'UTC' })
iterator.next().getTime();

This seems to be the cause: https://github.com/harrisiirak/cron-parser/blob/master/lib/date.js#L227. The !timestamp will give true for a timestamp of 0 but arguably this should be accepted as a valid timestamp. I was using this in my tests which started failing when updating beyond version 3.0.0.

Is this a bug or is it intended?

sbruinsje avatar Sep 15 '22 15:09 sbruinsje