Day of week vs Day of month
See original GitHub issueHey @merencia,
First of all, thank you so much for the library, very good job!
I wanted to ask you a question regarding the way node-cron is matching task against Day of week and Day of month.
In the specification of crontab, we have:
Finally, if either the month or day of month is specified as an element or list, and the day of week is also specified as an element or list, then any day matching either the month and day of month, or the day of week, shall be matched. – http://pubs.opengroup.org/onlinepubs/007904975/utilities/crontab.html
Which mean in your code we should have something like:
var runOnDay = false;
if (task.initialPatterns[3] === '*') {
runOnDay = matchPattern(task.expressions[5], date.getDay());
} else if (task.initialPatterns[5] === '*')
runOnDay = matchPattern(task.expressions[3], date.getDate());
} else {
runOnDay = matchPattern(task.expressions[3], date.getDate()) || matchPattern(task.expressions[5], date.getDay());
}
return runInSecond && runOnMinute && runOnHour && runOnMonth && runOnDay;
With this.initialPatterns = pattern.split(' ');
in the Task
constructor.
I just want to highlight that node-cron
does not match the standard specification of the crontab, which frankly I prefer since it helps us doing things like 0 10 1-7 * 1
= Every first Monday of the month at 10am
.
So finally, my question. Could you either:
- put somewhere in the documentation that
node-cron
is not matching days like the standard for crontab - or change the code to match the specification
Thanks,
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Hello @bchelli, sorry about the delay, I was on vacations and I was 15 days without internet 😄
I really prefer the option 2, but unfortunately I can’t code on node-cron in the next weeks.
Would you like to help me on node-cron?
btw, I’ve added you as collaborator on node-cron repository.