19 releases (breaking)

0.13.0 Nov 6, 2024
0.12.1 Feb 29, 2024
0.12.0 Sep 24, 2022
0.11.0 Apr 14, 2022
0.0.2 Jun 27, 2015

#6 in Date and time

Download history 33076/week @ 2024-08-13 34608/week @ 2024-08-20 34441/week @ 2024-08-27 37189/week @ 2024-09-03 35732/week @ 2024-09-10 35260/week @ 2024-09-17 41955/week @ 2024-09-24 41494/week @ 2024-10-01 40873/week @ 2024-10-08 46493/week @ 2024-10-15 48604/week @ 2024-10-22 48481/week @ 2024-10-29 45496/week @ 2024-11-05 47256/week @ 2024-11-12 49788/week @ 2024-11-19 46134/week @ 2024-11-26

197,166 downloads per month
Used in 198 crates (100 directly)

MIT/Apache

86KB
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–7MB
~47K SLoC