When scheduling a job using a step interval for the day-of-week field (for example, 2/2 to run every 2 days starting on Tuesday), the parser incorrectly includes Sunday (0) in the resolved days. This causes the job to ru…
When scheduling a job using a step interval for the day-of-week field (for example, 2/2 to run every 2 days starting on Tuesday), the parser incorrectly includes Sunday (0) in the resolved days. This causes the job to run on Sundays in addition to the expected days, even though the step sequence never actually lands on Sunday.
0 0 * * 2/2 (which is meant to run at midnight on Tuesday, Thursday, and Saturday).const { CronExpressionParser } = require('cron-parser');
const parsed = CronExpressionParser.parse('0 0 * * 2/2');
console.log(parsed.fields.dayOfWeek.values);
The resolved day-of-week values should only contain the days matching the step sequence:
[2, 4, 6] (Tuesday, Thursday, Saturday)
The resolved day-of-week values incorrectly include Sunday:
[0, 2, 4, 6] (Sunday, Tuesday, Thursday, Saturday)
This issue affects step intervals on the day-of-week field where the step sequence does not land on Sunday (day 7). For example, 2/2 (Tuesday, Thursday, Saturday) incorrectly includes Sunday, whereas 1/2 (Monday, Wednesday, Friday, Sunday) correctly includes Sunday because the step sequence lands on 7.
Adapted from harrisiirak/cron-parser (MIT).
Visible test command
npm test -- --testPathPattern=visibleThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
cron-dow-step-sunday
Changes under src/ are evaluated.