18 releases (breaking)

0.12.1 Feb 29, 2024
0.12.0 Sep 24, 2022
0.11.0 Apr 14, 2022
0.10.0 Mar 21, 2022
0.0.2 Jun 27, 2015

#6 in Date and time

Download history 13147/week @ 2023-12-23 16106/week @ 2023-12-30 18337/week @ 2024-01-06 19905/week @ 2024-01-13 21814/week @ 2024-01-20 22890/week @ 2024-01-27 20004/week @ 2024-02-03 17546/week @ 2024-02-10 20502/week @ 2024-02-17 22136/week @ 2024-02-24 22340/week @ 2024-03-02 23337/week @ 2024-03-09 26012/week @ 2024-03-16 25359/week @ 2024-03-23 22588/week @ 2024-03-30 21392/week @ 2024-04-06

99,474 downloads per month
Used in 162 crates (80 directly)

MIT/Apache

71KB
2K SLoC

cron Rust

A cron expression parser. Works with stable Rust v1.28.0.

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.9–9MB
~45K SLoC