use jiff::Timestamp;
use jiff::tz::TimeZone;
use ohno::IntoAppError;
use tick::Clock;
const JIFF_DISPLAY_FORMAT: &str = "%Y-%m-%d %H:%M:%S";
fn main() -> Result<(), ohno::AppError> {
let clock = Clock::new_frozen();
let timestamp = clock.system_time_as::<Timestamp>();
println!("Current time (UTC): {}", timestamp.strftime(JIFF_DISPLAY_FORMAT));
let zoned = timestamp.in_tz("Asia/Tokyo")?;
println!("Current time (Asia/Tokyo): {}", zoned.strftime(JIFF_DISPLAY_FORMAT));
let zoned = timestamp.to_zoned(TimeZone::system());
println!(
"Current time ({}): {}",
TimeZone::system().iana_name().into_app_err("failed to get time zone name")?,
zoned.strftime(JIFF_DISPLAY_FORMAT)
);
println!("Current time in RFC 9557 format: {zoned}");
Ok(())
}