a simple tool to compute time: easy to config, and easy to use. a simple example:
``` use std::time::Duration; use time::OffsetDateTime; use timer_util::*;
async fn main() -> anyhow::Result<()> { // 定时器配置(timer configs): // every weekday or 1st..10st 15st..25st every month 每周六 或者每月的1号到9号、15号到24号 // every hour 每小时 // 0st/10st/20st/30st/40st/50st minuter 第0/10/20/30/40/50分钟 // 0st/30st second 第0/30秒 let conf = DayHourMinuterSecondConf::defaultweekdays(WeekDays::defaultvalue(W6)) .confmonthdays(MonthDays::defaultrange(D1..D10)?.addrange(D15..D25)?) .buildwithhours(Hours::defaultall()) .buildwithminuter(Minuters::defaultarray(&[M0, M10, M20, M30, M40, M50])) .buildwithsecond(Seconds::defaultarray(&[S0, S30]));
// let next_seconds = conf.next()?;
let handle = tokio::spawn(async move {
loop {
let off_seconds = conf.next().unwrap();
println!("next seconds: {}", off_seconds);
tokio::time::sleep(Duration::from_secs(off_seconds)).await;
// println!("{:?}", OffsetDateTime::now_local().unwrap());
}
});
handle.await.unwrap();
Ok(())
}
```