#cron #schedule #repeat #periodic #time

cron

A cron expression parser and schedule explorer

13 releases (breaking)

0.9.0 Mar 22, 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

#11 in Date and time

Download history 1753/week @ 2021-01-21 1372/week @ 2021-01-28 1649/week @ 2021-02-04 2116/week @ 2021-02-11 3136/week @ 2021-02-18 2668/week @ 2021-02-25 2572/week @ 2021-03-04 2996/week @ 2021-03-11 2982/week @ 2021-03-18 3286/week @ 2021-03-25 3239/week @ 2021-04-01 3984/week @ 2021-04-08 4186/week @ 2021-04-15 3095/week @ 2021-04-22 3459/week @ 2021-04-29 2548/week @ 2021-05-06

13,869 downloads per month
Used in 17 crates (15 directly)

MIT/Apache

67KB
2K SLoC

cron Rust

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
*/

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1.5MB
~30K SLoC