#cron #schedule #repeat #periodic #time

cron

A cron expression parser and schedule explorer

9 releases (breaking)

new 0.6.0 Aug 8, 2018
0.5.0 Aug 6, 2018
0.4.1 Jun 1, 2018
0.4.0 Aug 4, 2017
0.0.2 Jun 27, 2015

#15 in Date and time

Download history 22/week @ 2018-05-17 48/week @ 2018-05-24 68/week @ 2018-05-31 55/week @ 2018-06-07 25/week @ 2018-06-14 29/week @ 2018-06-21 79/week @ 2018-06-28 31/week @ 2018-07-05 14/week @ 2018-07-12 43/week @ 2018-07-19 45/week @ 2018-07-26 66/week @ 2018-08-02 107/week @ 2018-08-09

210 downloads per month

cron

A Cron Expression Parser in Rust

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
*/

lib.rs:

A cron expression parser and schedule explorer

Example

extern crate chrono;
extern crate cron;

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
*/
MIT license

Dependencies

Reverse deps