Skip to content
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

Problem with range matching. #11

Closed
gmosx opened this issue Oct 16, 2024 · 5 comments
Closed

Problem with range matching. #11

gmosx opened this issue Oct 16, 2024 · 5 comments

Comments

@gmosx
Copy link

gmosx commented Oct 16, 2024

Hi!

First of all, thank you for this useful crate. I would like to report an issue:

The cron expression 0 0 15-21 3 5 should match a Friday in March that's between the days 15-21.

In other words it should match 15-21 AND 5, i.e. "3-15".

Instead it seems to match 15-21 OR 5, i.e. "3-1" "3-8" "3-15" "3-16" "3-17" "3-18" "3-19" "3-20" "3-21" "3-22" "3-29".

@Hexagon
Copy link
Owner

Hexagon commented Oct 16, 2024

Hello! That's expected behavior of cron, but croner has an option for using OR instead of AND - https://github.com/Hexagon/croner-rust?tab=readme-ov-file#3-with_dom_and_dow . Does that work for you?

@Hexagon
Copy link
Owner

Hexagon commented Oct 16, 2024

Background (from developing the javascript version of croner): Hexagon/croner#53

@gmosx
Copy link
Author

gmosx commented Oct 17, 2024

Interesting, it worked, thank you!

@gmosx
Copy link
Author

gmosx commented Oct 17, 2024

Closing this issue as my problem is resolved.

But, a thought: shouldn't .with_dom_and_dow() be the default?

@gmosx gmosx closed this as completed Oct 17, 2024
@Hexagon
Copy link
Owner

Hexagon commented Oct 17, 2024

Great!

OR is the default in most cron implementations, including the POSIX crontab specification

As an example of specifying the two types of days:

0 0 1,15 * 1

would run a command on the first and fifteenth of each month, as well as on every Monday. To specify days by only one field, the other field should be set to '*'; for example:

https://pubs.opengroup.org/onlinepubs/9799919799/utilities/crontab.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants