You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constcronParser=require('cron-parser');// START DATE NOT INCLUDEDtry{constintervalCron=cronParser.parseExpression('0 12 * * *',{tz: 'UTC',currentDate: newDate('2020-02-19T12:00:00.000000+00:00'),endDate: newDate('2020-02-19T13:00:00.000000+00:00'),});constnextRun=intervalCron.next().toDate();console.log({ nextRun });}catch(error){console.error(error.message);}// END DATE INCLUDEDconstintervalCron=cronParser.parseExpression('0 13 * * *',{tz: 'UTC',currentDate: newDate('2020-02-19T12:00:00.000000+00:00'),endDate: newDate('2020-02-19T13:00:00.000000+00:00'),});constnextRun=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?
The text was updated successfully, but these errors were encountered:
It should be theoretically inclusive range, but there is this workaround to ensure that we won't get stuck into loop without time iteration. This is going to break inclusive range for seconds in that sense. If removed, it will fix your use case and it will return expected behaviour, but will break some others (in the tests).
If you provide * 0 12 * * * (currently it defaults to 0 0 12 * * * if you don't specify seconds), it will also work, but instead of 2020-02-19T12:00:00, you will get 2020-02-19T12:00:01 as nextRun value. Therefore, it will not behave as inclusive range.
Ideally it should also work as inclusive range, but I don't have enough time at the moment to create a proper bugfix (yeah, it's a bug) for that.
Hi,
given the following example:
By using the
currentDate
andendDate
as the timespan range, it seems that theendDate
is included whilecurrentDate
is not:currentDate < next-cron <= endDate
.I think the
currentDate
should be included and the first example should work without throwing theOut of the timespan range
error.WDYT?
The text was updated successfully, but these errors were encountered: