use std::time::Duration;
use tick::Clock;
use tick::fmt::{Iso8601, Rfc2822};
#[tokio::main]
async fn main() -> Result<(), ohno::AppError> {
let clock = Clock::new_tokio();
let stopwatch = clock.stopwatch();
clock.delay(Duration::from_secs(2)).await;
println!("Elapsed time: {}ms", stopwatch.elapsed().as_millis());
let time = clock.system_time();
let iso: Iso8601 = time.try_into()?;
let rfc: Rfc2822 = time.try_into()?;
println!("Current time (ISO 8601): {iso}");
println!("Current time (RFC 2822): {rfc}");
clock.delay(Duration::from_secs(1)).await;
let new_time = clock.system_time();
let diff = new_time.duration_since(time)?;
println!("Time difference: {}ms", diff.as_millis());
Ok(())
}