#cron #schedule #repeat #blockchain #near

cron_schedule

A cron expression parser, adapted for blockchain environments

4 releases

0.2.2 Sep 15, 2022
0.2.1 Sep 15, 2022
0.2.0 Apr 17, 2021
0.1.0 Apr 16, 2021

#6 in #near

Download history 3/week @ 2022-06-12 10/week @ 2022-06-19 55/week @ 2022-06-26 33/week @ 2022-07-03 56/week @ 2022-07-10 103/week @ 2022-07-17 138/week @ 2022-07-24 87/week @ 2022-07-31 172/week @ 2022-08-07 221/week @ 2022-08-14 140/week @ 2022-08-21 3/week @ 2022-08-28 150/week @ 2022-09-04 295/week @ 2022-09-11 196/week @ 2022-09-18 174/week @ 2022-09-25

816 downloads per month

MIT license

57KB
1.5K SLoC

cron_schedule

A cron expression parser, adapted for blockchain environments..

extern crate cron_schedule;
extern crate chrono;

use cron_schedule::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  2021/2";
  let schedule = Schedule::from_str(expression).unwrap();
  println!("Upcoming fire times:");
  for datetime in schedule.upcoming().take(10) {
    println!("-> {}", datetime);
  }
}

/*
Upcoming fire times:
-> 2021-06-01 09:30:00 UTC
-> 2021-06-01 12:30:00 UTC
-> 2021-06-01 15:30:00 UTC
-> 2021-06-15 09:30:00 UTC
-> 2021-06-15 12:30:00 UTC
-> 2021-06-15 15:30:00 UTC
-> 2021-08-01 09:30:00 UTC
-> 2021-08-01 12:30:00 UTC
-> 2021-08-01 15:30:00 UTC
-> 2021-08-15 09:30:00 UTC
*/

License

MIT license (LICENSE or http://opensource.org/licenses/MIT)

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
~32K SLoC