expressive-cron
A fluent builder for cron expressions, inspired by Laravel.
From crates.io
Version 0.1.0
Updated May 13, 2026
28 downloads
Install
Run this in your project folder. cargo add expressive-cron
Expressive Cron
A fluent builder for cron expressions, inspired by Laravel.
Features
- Fluent Builder: Chain frequency helpers (
daily,hourly_at,weekdays,every_five_minutes, …) to build a cron expression without thinking about field positions. - Type-Safe Days: Use the
DayOfWeekenum instead of stringly-typed numerics —cron.days(DayOfWeek::Monday)instead ofcron.days("1"). - Polymorphic Fields: Methods accept any
impl IntoCronValue, sohourly_at(37),hourly_at("*/10"), andhourly_at([15, 30, 45])all work. - Filter Hooks: Attach arbitrary closures with
when/skip, or use built-in time-of-day windows viabetween/unless_between. - Timezone-Aware: Time-based filters are evaluated in a configurable
chrono_tz::Tz.
Usage
use expressive_cron::{Cron, DayOfWeek};
let mut cron = Cron::new();
cron.every_five_minutes()
.between("09:00", "17:00")
.weekdays();
assert_eq!("*/5 * * * 1-5", cron.expression());
assert!(cron.filters_pass()); // true when called inside the window on a weekday
let mut nightly = Cron::new();
nightly.hourly_at([15, 30, 45]).days(DayOfWeek::Sunday);
assert_eq!("15,30,45 * * * 0", nightly.expression());
Please refer to the documentation on docs.rs for detailed usage instructions.
License
This project is licensed under the MIT License - see the LICENSE file for details.