12 releases (breaking)
0.8.0 | Feb 5, 2021 |
---|---|
0.7.0 | Nov 21, 2020 |
0.6.1 | Jun 13, 2020 |
0.6.0 | Aug 8, 2018 |
0.0.2 | Jun 27, 2015 |
#8 in Date and time
5,767 downloads per month
Used in 14 crates
(12 directly)
59KB
1.5K
SLoC
cron

A cron expression parser. Works with stable Rust v1.28.0.
extern crate cron;
extern crate chrono;
use cron::Schedule;
use chrono::Utc;
use std::str::FromStr;
fn main() {
// sec min hour day of month month day of week year
let expression = "0 30 9,12,15 1,15 May-Aug Mon,Wed,Fri 2018/2";
let schedule = Schedule::from_str(expression).unwrap();
println!("Upcoming fire times:");
for datetime in schedule.upcoming(Utc).take(10) {
println!("-> {}", datetime);
}
}
/*
Upcoming fire times:
-> 2018-06-01 09:30:00 UTC
-> 2018-06-01 12:30:00 UTC
-> 2018-06-01 15:30:00 UTC
-> 2018-06-15 09:30:00 UTC
-> 2018-06-15 12:30:00 UTC
-> 2018-06-15 15:30:00 UTC
-> 2018-08-01 09:30:00 UTC
-> 2018-08-01 12:30:00 UTC
-> 2018-08-01 15:30:00 UTC
-> 2018-08-15 09:30:00 UTC
*/
Dependencies
~1.5MB
~27K SLoC