Closed Hellager closed 2 years ago
For now, it's ok to do it like this
// after the JobScheduler start
use cron::{Schedule as Cron_Schedule};
use chrono::{Utc, DateTime};
use std::str::FromStr;
.....
let cron_expression = "1/10 * * * * *";
sched.add(Job::new("1/10 * * * * *", |uuid, l| {
let cron_schedule = Cron_Schedule::from_str(&cron_expression).unwrap();
let next_run_time_vec: Vec<DateTime<Utc>> = cron_schedule.upcoming(Utc).take(1)
.filter_map(|datetime| Some(datetime)).collect::<Vec<DateTime<Utc>>>();
println!("cron job next run time: {}", next_run_time_vec[0].to_string());
}).await.unwrap());
Hi @Hellager Thanks for the post - I'll check into this
So @Hellager Have a look https://github.com/mvniekerk/tokio-cron-scheduler/releases/tag/v0.8.1
Implemented.
Thanks for your greet job, this crate works very well. I did found that there's a function time_till_next_job but it's not specified for a job, can there has an api to get a specific job's next_run_time like this get_next_run_time?