pub fn now_secs() -> u64 {
std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap_or_default()
.as_secs()
}
pub fn now_millis() -> u64 {
std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap_or_default()
.as_millis() as u64
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_now_secs_reasonable() {
let ts = now_secs();
assert!(ts > 1_704_067_200, "timestamp should be after 2024");
assert!(ts < 4_102_444_800, "timestamp should be before 2100");
}
#[test]
fn test_now_millis_monotonic() {
let a = now_millis();
let b = now_millis();
assert!(b >= a);
}
}