expressive-cron 0.1.0

A fluent builder for cron expressions, inspired by Laravel.
Documentation
  • Coverage
  • 90.91%
    70 out of 77 items documented0 out of 66 items with examples
  • Size
  • Source code size: 38.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 265.8 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • m1guelpf/expressive-cron
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • m1guelpf

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.