16 releases (breaking)

Uses new Rust 2021

0.11.0 Apr 14, 2022
0.10.0 Mar 21, 2022
0.9.0 Mar 22, 2021
0.7.0 Nov 21, 2020
0.0.2 Jun 27, 2015

#7 in Date and time

Download history 5704/week @ 2022-01-30 6623/week @ 2022-02-06 6181/week @ 2022-02-13 5485/week @ 2022-02-20 5538/week @ 2022-02-27 4794/week @ 2022-03-06 5315/week @ 2022-03-13 5311/week @ 2022-03-20 5834/week @ 2022-03-27 5942/week @ 2022-04-03 6340/week @ 2022-04-10 5807/week @ 2022-04-17 7315/week @ 2022-04-24 6501/week @ 2022-05-01 5305/week @ 2022-05-08 5687/week @ 2022-05-15

25,218 downloads per month
Used in 34 crates (23 directly)

MIT/Apache

69KB
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

~2MB
~31K SLoC