use std::time::SystemTime;
use chrono::{Local, TimeZone};
pub fn now_secs() -> u64 {
secs_since_epoch(SystemTime::now())
}
pub(crate) fn format_local(ts: u64) -> String {
let ts = i64::try_from(ts).unwrap_or(i64::MAX);
Local.timestamp_opt(ts, 0).single().map_or_else(
|| "—".to_string(),
|dt| dt.format("%Y-%m-%d %H:%M:%S %z").to_string(),
)
}
fn secs_since_epoch(moment: SystemTime) -> u64 {
moment
.duration_since(SystemTime::UNIX_EPOCH)
.map_or(0, |elapsed| elapsed.as_secs())
}
#[cfg(test)]
#[path = "time_tests.rs"]
mod time_tests;