You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Deno.cron Day-of-Week mismatch: Numeric weekdays off by one #21555
There is an inconsistency with the numeric representation of weekdays in the Deno.cron function, it is off by one compared to standards.
Expected Behavior:
Based on conventional "system cron" logic (as detailed in the references listed below), the expression * * * * 3 should denote every minute of every Wednesday. This follows the typical numbering of days where Sunday is 0, Monday is 1, and so forth.
In Deno, the expression * * * * 4 is required to trigger events every minute on Wednesdays. This originates from the Rust crate saffron.
Saffron, as explained in a Cloudflare blog post, is influenced by the (Java) Quartz scheduler's cron parser. Quartz adopts a different standard where the week starts with 1 (Sunday) and ends with 7 (Saturday). This is also documented in saffronissue #19.
Concern:
The main concern is the adoption of Quartz's weekday numbering in Deno, which contradicts the more widely accepted system cron standard (0 for Sunday, 1 for Monday, etc.).
Alternative Solution:
In response to this (and other issues with existing Rust cron implementations), I have created an alternative crate, croner, which aims to align more closely with the standard cron behavior, and extend them with commonly adopted additional features. A detailed comparison between croner and the existing cron and saffron crates can be found at Why Croner instead of Cron or Saffron? (Disclaimer: This comparison is based on my own quick tests, as documentation for the other crates is limited.).
From version 2.0.0, croner defaults to POSIX-style, as it did in 1.0.0, but can optionally switch to Quartz-mode using the builder method .with_alternative_weekdays(). I'd really like to see Deno.cron use POSIX style by default, but have the option to switch to Quartz mode using an option in Deno.cron.
Not too long ago, saffron was removed as a dependency (#34879), yet full support for the specific saffron cron syntax was retained in cron.rs.
Because of this, I believe we should update the documentation in two places (one, two) that currently point to standard cron syntax conventions. We should explicitly state that the day-of-week field uses a 1-7 numerical range (similar to how it is documented in the Deploy Classic docs), which would finally clear up any confusion and close this issue.
Activity
Hexagon commentedon Dec 17, 2023
From version
2.0.0, croner defaults to POSIX-style, as it did in1.0.0, but can optionally switch to Quartz-mode using the builder method.with_alternative_weekdays(). I'd really like to see Deno.cron use POSIX style by default, but have the option to switch to Quartz mode using an option inDeno.cron.Hexagon commentedon Mar 24, 2024
I just noticed that your documentation points to crontab.guru, which uses different weekday numbering compared to Deno.
igorzi commentedon Mar 26, 2024
Docs are updated.
sanekb commentedon Jul 3, 2026
Not too long ago,
saffronwas removed as a dependency (#34879), yet full support for the specific saffron cron syntax was retained incron.rs.Because of this, I believe we should update the documentation in two places (one, two) that currently point to standard cron syntax conventions. We should explicitly state that the day-of-week field uses a 1-7 numerical range (similar to how it is documented in the Deploy Classic docs), which would finally clear up any confusion and close this issue.
Thoughts on this, @bartlomieju?
bartlomieju commentedon Jul 6, 2026
Sure, PRs welcome