-
Notifications
You must be signed in to change notification settings - Fork 162
Open
Labels
Description
Hi,
given the following example:
const cronParser = require('cron-parser');
// START DATE NOT INCLUDED
try {
const intervalCron = cronParser.parseExpression('0 12 * * *', {
tz: 'UTC',
currentDate: new Date('2020-02-19T12:00:00.000000+00:00'),
endDate: new Date('2020-02-19T13:00:00.000000+00:00'),
});
const nextRun = intervalCron.next().toDate();
console.log({ nextRun });
} catch (error) {
console.error(error.message);
}
// END DATE INCLUDED
const intervalCron = cronParser.parseExpression('0 13 * * *', {
tz: 'UTC',
currentDate: new Date('2020-02-19T12:00:00.000000+00:00'),
endDate: new Date('2020-02-19T13:00:00.000000+00:00'),
});
const nextRun = intervalCron.next().toDate();
console.log({ nextRun });By using the currentDate and endDate as the timespan range, it seems that the endDate is included while currentDate is not: currentDate < next-cron <= endDate.
I think the currentDate should be included and the first example should work without throwing the Out of the timespan range error.
WDYT?
Reactions are currently unavailable