canic_backup/timestamp/
mod.rs1use std::time::{SystemTime, UNIX_EPOCH};
8
9#[must_use]
11pub fn current_timestamp_marker() -> String {
12 let seconds = SystemTime::now()
13 .duration_since(UNIX_EPOCH)
14 .map_or(0, |duration| duration.as_secs());
15
16 format!("unix:{seconds}")
17}
18
19#[cfg(test)]
20mod tests {
21 use super::*;
22
23 #[test]
25 fn current_timestamp_marker_uses_unix_prefix() {
26 let marker = current_timestamp_marker();
27 let seconds = marker
28 .strip_prefix("unix:")
29 .expect("timestamp marker should include prefix");
30
31 assert!(seconds.parse::<u64>().is_ok());
32 }
33}