hron 0.6.0

Human-readable cron — scheduling expressions that are a superset of what cron can express
Documentation

hron (Rust)

Native Rust implementation of hron — human-readable cron expressions.

Install

cargo add hron

By default, serde support is included. For a minimal build with only jiff as a dependency:

[dependencies]
hron = { version = "*", default-features = false }

Usage

use hron::Schedule;
use jiff::Zoned;

// Parse an expression
let schedule: Schedule = "every weekday at 9:00 in America/New_York".parse().unwrap();

// Compute next occurrence
let now = Zoned::now();
let next = schedule.next_from(&now).unwrap();

// Compute next N occurrences
let next_five = schedule.next_n_from(&now, 5).unwrap();

// Check if a datetime matches
let matches = schedule.matches(&now).unwrap();

// Convert to cron (expressible subset only)
let cron = Schedule::parse("every day at 9:00").unwrap().to_cron().unwrap();

// Convert from cron
let from_cron = Schedule::from_cron("0 9 * * *").unwrap();

// Canonical string (roundtrip-safe)
println!("{schedule}");

Tests

cargo test

Conformance tests driven by spec/tests.json.

License

MIT