380 releases
0.1.382 | Dec 1, 2023 |
---|---|
0.1.381 | Nov 30, 2023 |
0.1.350 | Oct 31, 2023 |
0.1.258 | Jul 31, 2023 |
0.1.15 | Nov 30, 2022 |
#33 in #schedule
122 downloads per month
Used in chronos-scheduler-rs
26KB
643 lines
chronos-parser-rs
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
Dependencies
~3.5–5MB
~87K SLoC