I using this code to do an interval in rust:
use std::time::Duration; use tokio::time; #[tokio::main] async fn main() { let mut interval = time::interval(Duration::from_millis(10000)); loop { interval.tick().await; println!("{}","trigger") } } When I want to set the interval to 1 hour, I have to write the Duration like this 1000 * 60 * 60. is there any simple way just like Duration::hours(1)? I have tried chrono but seems it is not compatible with Tokio.
from_secswhich only requires60 * 60, or you can use chrono andchrono::Duration::to_stdto make it compatible withtokio::time::interval.