11 releases (7 breaking)

Uses old Rust 2015

new 0.7.0 Nov 21, 2020
0.6.1 Jun 13, 2020
0.6.0 Aug 8, 2018
0.4.1 Jun 1, 2018
0.0.2 Jun 27, 2015

#15 in Date and time

Download history 1446/week @ 2020-08-07 1014/week @ 2020-08-14 1113/week @ 2020-08-21 1098/week @ 2020-08-28 1346/week @ 2020-09-04 2438/week @ 2020-09-11 1462/week @ 2020-09-18 2276/week @ 2020-09-25 1864/week @ 2020-10-02 1337/week @ 2020-10-09 2058/week @ 2020-10-16 1510/week @ 2020-10-23 1944/week @ 2020-10-30 1400/week @ 2020-11-06 994/week @ 2020-11-13 1472/week @ 2020-11-20

6,882 downloads per month
Used in 10 crates (9 directly)

MIT license

42KB
1K SLoC

cron

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

~2MB
~35K SLoC