chronos-parser-rs

Crates.iochronos-parser-rs
lib.rschronos-parser-rs
version0.1.382
sourcesrc
created_at2022-11-17 00:23:22.800891
updated_at2023-12-01 00:19:24.714287
descriptionA Rust crate for CROND parser.
homepage
repositoryhttps://github.com/j5ik2o/chronos-parser-rs
max_upload_size
id716811
size44,036
Junichi Kato (j5ik2o)

documentation

README

chronos-parser-rs

Workflow Status crates.io docs.rs Renovate dependency status License License

A Rust crate for CROND parser.

Installation

Add the following configuration to Cargo.toml.

[dependencies]
chronos-parser-rs = "0.1.XXX"

Usage

// Create a new cron schedule
let cron_schedule = CronSchedule::new("0-59/30 0-23/2 * * *").unwrap();

// Create a DateTime object representing January 1, 2021, 1:01:00 AM (UTC)
let dt: chrono::DateTime<Utc> = Utc.with_ymd_and_hms(2021, 1, 1, 1, 1, 0).unwrap();
// Return an iterator that calculates the scheduled execution times after this date and time
let iterator = cron_schedule.upcoming(dt);

// Print the next 5 scheduled execution times
for next_trigger in iterator.take(5) {
  println!("{}", next_trigger);
}
2021-01-01T02:00:00Z
2021-01-01T02:30:00Z
2021-01-01T04:00:00Z
2021-01-01T04:30:00Z
2021-01-01T06:00:00Z

Related Crates

Implementations for Scala

Commit count: 499

cargo fmt