Crates.io | chronos-parser-rs |
lib.rs | chronos-parser-rs |
version | 0.1.382 |
source | src |
created_at | 2022-11-17 00:23:22.800891 |
updated_at | 2023-12-01 00:19:24.714287 |
description | A Rust crate for CROND parser. |
homepage | |
repository | https://github.com/j5ik2o/chronos-parser-rs |
max_upload_size | |
id | 716811 |
size | 44,036 |
A Rust crate for CROND parser.
Add the following configuration to Cargo.toml
.
[dependencies]
chronos-parser-rs = "0.1.XXX"
// 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