zslayton / cron

A cron expression parser in Rust
Apache License 2.0
356 stars 68 forks source link

Could it be the numerical values for day of week are off by one? #113

Open Thorongil80 opened 1 year ago

Thorongil80 commented 1 year ago

Hi,

I use job_scheduler https://docs.rs/job_scheduler/latest/job_scheduler/ which apparently pulls cron 0.6.1 as dependency.

I noticed that this expression

0 0 17 Mon-Sat

is not

0 0 17 1-6

Which according to crontab format however, it should be. The latter expression would fire on Sundays till Friday.

Are you one off in the numerical format for day-of-week?

Or were you one off back then with 0.6.1?

Should I ask job_scheduler to bump to newer version? I opened an issue with them https://github.com/lholden/job_scheduler/issues/29

Best Regards, Thomas

BlackDex commented 1 year ago

This crate isn't crontab compatible. For one, this crate supports seconds, which crontab doesn't allow at all. Looking at the code, it uses 1 for Sunday, and 7 for Saturday. https://github.com/zslayton/cron/blob/9d54fb7d1c1679136d92f411a7403b774a92d56b/src/time_unit/days_of_week.rs#L32-L38

There is nothing other crates can do which implement this crate besides trying to catch the format and change it manually. But that will only lead into issues with people already using this format.

makerio90 commented 1 year ago

are there plans to add some sort of chrontab support?

zslayton commented 1 year ago

Please see this issue. This crate was coded against the Quartz scheduling engine's cron syntax specification. Unfortunately, there is no single definitive standard.

I'm open to supporting various standards via a builder/config API, but I don't have the bandwidth to work on this crate actively.