pub(crate) fn now_secs() -> u64 {
std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map(|d| d.as_secs())
.unwrap_or(0)
}
pub(crate) fn now_rfc3339() -> String {
rfc3339_from_unix(now_secs())
}
pub(crate) fn rfc3339_from_unix(secs: u64) -> String {
let tod = secs % 86_400;
let (hour, minute, second) = (tod / 3_600, (tod % 3_600) / 60, tod % 60);
let (year, month, day) = suno_core::days_to_civil(secs / 86_400);
format!("{year:04}-{month:02}-{day:02}T{hour:02}:{minute:02}:{second:02}Z")
}