mvm_core/time.rs
1/// Return the current UTC timestamp in ISO 8601 format.
2pub fn utc_now() -> String {
3 chrono::Utc::now().format("%Y-%m-%dT%H:%M:%SZ").to_string()
4}
5
6#[cfg(test)]
7mod tests {
8 use super::*;
9
10 #[test]
11 fn test_utc_now_format() {
12 let ts = utc_now();
13 assert!(ts.ends_with('Z'));
14 assert_eq!(ts.len(), 20);
15 assert_eq!(&ts[4..5], "-");
16 assert_eq!(&ts[7..8], "-");
17 assert_eq!(&ts[10..11], "T");
18 }
19}