clockwork_cron/lib.rs
1#![deny(rust_2018_idioms)]
2
3//! A cron expression parser and schedule explorer
4//! # Example
5//! ```
6//! use clockwork_cron::Schedule;
7//! use chrono::{DateTime, NaiveDateTime, Utc};
8//! use std::str::FromStr;
9//!
10//! fn main() {
11//! // sec min hour day of month month day of week year
12//! let expression = "0 30 9,12,15 1,15 May-Aug Mon,Wed,Fri 2018/2";
13//! let schedule = Schedule::from_str(expression).unwrap();
14//! let ts = 1234567890;
15//! let next_ts = match schedule
16//! .after(&DateTime::<Utc>::from_utc(
17//! NaiveDateTime::from_timestamp(ts, 0),
18//! Utc,
19//! ))
20//! .take(1)
21//! .next()
22//! {
23//! Some(datetime) => Some(datetime.timestamp()),
24//! None => None,
25//! };
26//! }
27//!
28//! /*
29//! Upcoming fire times:
30//! -> 2018-06-01 09:30:00 UTC
31//! -> 2018-06-01 12:30:00 UTC
32//! -> 2018-06-01 15:30:00 UTC
33//! -> 2018-06-15 09:30:00 UTC
34//! -> 2018-06-15 12:30:00 UTC
35//! -> 2018-06-15 15:30:00 UTC
36//! -> 2018-08-01 09:30:00 UTC
37//! -> 2018-08-01 12:30:00 UTC
38//! -> 2018-08-01 15:30:00 UTC
39//! -> 2018-08-15 09:30:00 UTC
40//! */
41//! ```
42
43pub mod error;
44mod ordinal;
45mod parsing;
46mod queries;
47mod schedule;
48mod specifier;
49mod time_unit;
50
51pub use crate::schedule::Schedule;
52pub use crate::time_unit::TimeUnitSpec;