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

Download history 1303/week @ 2020-11-07 859/week @ 2020-11-14 2113/week @ 2020-11-21 1796/week @ 2020-11-28 1304/week @ 2020-12-05 1333/week @ 2020-12-12 698/week @ 2020-12-19 774/week @ 2020-12-26 1211/week @ 2021-01-02 1489/week @ 2021-01-09 1415/week @ 2021-01-16 1740/week @ 2021-01-23 1442/week @ 2021-01-30 1488/week @ 2021-02-06 2873/week @ 2021-02-13 2584/week @ 2021-02-20

5,767 downloads per month
Used in 14 crates (12 directly)

MIT license

59KB
1.5K 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
*/

Dependencies

~1.5MB
~27K SLoC