-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cron.matchDate returns always true when using weekdays and days of month #270
Comments
Hello @renzo-s 👋 Thank you for your feedback. The expression 0-6 in the weekdays field will not result in only Saturdays or sundays, but will allow any weekday between 0 (Sunday) and 6 (Saturday), which includes 1 (Monday), 2 (Tuesday), …, which at the end is every weekday. The logic that either day of month or weekday needs to match, comes from this note from crontab.org:
So you are right, that this check is wrong, when one of the fields is not restricted. |
Hi Pascal, 🙈 damn that was a silly typo. I'm using Ah, thanks for the spec note, now the brackets and the OR make sense. This just needs another |
…er weekday or day of month is unrestricted (#271) * resolves #270 * resolves #270 Co-authored-by: Renzo Sartorius <[email protected]>
🎉 This issue has been resolved in version 3.0.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Because of this line in matchDate:
(this.days.indexOf(day) !== -1 || this.weekdays.indexOf(weekday) !== -1)
an expression like* * * * * 0,6
(Only on Saturday's or Sunday's) will always return true sinceindexOf(day)
will always return true. I believe correct would be using logical AND instead of OR.Thanks for the package, just what I was looking for. This behaviour is not hard to overwrite, just letting you know 👍
Ref:
cron-schedule/src/cron.ts
Line 538 in 777e7d3
The text was updated successfully, but these errors were encountered: