saffron is a cron parser used as part of the backend for Cron Triggers in Cloudflare Workers. It provides APIs for the complete stack, allowing us to use the same parser everywhere. It's made in two parts:
The parser, which is responsible for reading cron expressions into an easy to understand format,
which can be simplified with the compiler, or described with CronExpr::describe
.
The compiler, which simplifies expressions into their most compact form. This compact form can check if a chrono date time is contained in a given expression in constant time, no matter the size of the original expression. It can also be used to get future times that match efficiently as an iterator.
The project itself is divided into 4 Rust workspace members: