harrisiirak/cron-parser

Repeatable day of month not working when providing day of week

dhulke opened this issue · 0 comments

The first set of next() calls are working as expected, but when I change the cron expression to filter by day of week, the results become unpredictable. Could this be related to this other issue #284 where 1-5 is being treated as a wild card match?

const parser = require('cron-parser');

const intervalEveryDay = parser.parseExpression('0 0 */3 * *');

console.log('Every day');
console.log('Date: ', intervalEveryDay.next().toString()); // Thu Apr 04 2024 00:00:00 GMT-0300 (Brasilia Standard Time)
console.log('Date: ', intervalEveryDay.next().toString()); // Sun Apr 07 2024 00:00:00 GMT-0300 (Brasilia Standard Time)
console.log('Date: ', intervalEveryDay.next().toString()); // Wed Apr 10 2024 00:00:00 GMT-0300 (Brasilia Standard Time)
console.log('Date: ', intervalEveryDay.next().toString()); // Sat Apr 13 2024 00:00:00 GMT-0300 (Brasilia Standard Time)

const intervalWeekDay = parser.parseExpression('0 0 */3 * 1-5');

console.log('Week days');
console.log('Date: ', intervalWeekDay.next().toString()); // Thu Apr 04 2024 00:00:00 GMT-0300 (Brasilia Standard Time)
console.log('Date: ', intervalWeekDay.next().toString()); // Fri Apr 05 2024 00:00:00 GMT-0300 (Brasilia Standard Time)
console.log('Date: ', intervalWeekDay.next().toString()); // Sun Apr 07 2024 00:00:00 GMT-0300 (Brasilia Standard Time)
console.log('Date: ', intervalWeekDay.next().toString()); // Mon Apr 08 2024 00:00:00 GMT-0300 (Brasilia Standard Time)\