use chrono::{Utc, SecondsFormat};
pub fn timestamp_millis() -> u64 {
Utc::now().timestamp_millis() as u64
}
pub fn timestamp_seconds() -> u64 {
Utc::now().timestamp() as u64
}
pub fn timestamp_iso8601() -> String {
Utc::now().to_rfc3339_opts(SecondsFormat::Millis, true)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_timestamp_millis() {
let ts = timestamp_millis();
assert!(ts > 1700000000000); }
#[test]
fn test_timestamp_seconds() {
let ts = timestamp_seconds();
assert!(ts > 1700000000); }
#[test]
fn test_timestamp_iso8601() {
let ts = timestamp_iso8601();
assert!(ts.contains("T"));
assert!(ts.ends_with("Z"));
}
}