pub fn format(time: std::time::SystemTime) -> String {
let seconds = time
.duration_since(std::time::UNIX_EPOCH)
.map_or(0, |since| since.as_secs());
crate::time::timestamp(seconds)
}
pub fn date(timestamp: &str) -> &str {
timestamp.get(..10).unwrap_or(timestamp)
}
pub fn iso8601(timestamp: &str) -> String {
format!("{}Z", timestamp.replacen(' ', "T", 1))
}
#[cfg(test)]
mod tests {
#[test]
fn short_values_do_not_panic() {
assert_eq!(super::date("2026"), "2026");
assert_eq!(super::date(""), "");
}
}