Skip to content
Free

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.

crates.io download count badge docs.rs

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 DayOfWeek enum instead of stringly-typed numerics — cron.days(DayOfWeek::Monday) instead of cron.days("1").
  • Polymorphic Fields: Methods accept any impl IntoCronValue, so hourly_at(37), hourly_at("*/10"), and hourly_at([15, 30, 45]) all work.
  • Filter Hooks: Attach arbitrary closures with when / skip, or use built-in time-of-day windows via between / 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.