openapi_rs/common/time.rs
1use std::time;
2
3pub fn current_timestamp() -> anyhow::Result<String> {
4 Ok(time::SystemTime::now()
5 .duration_since(time::UNIX_EPOCH)?
6 .as_secs()
7 .to_string())
8}
9
10#[cfg(test)]
11mod tests {
12 use super::*;
13
14 #[test]
15 fn test_current_timestamp() -> anyhow::Result<()> {
16 let timestamp = current_timestamp()?;
17 dbg!(×tamp);
18 assert!(timestamp.parse::<i64>().is_ok());
19 Ok(())
20 }
21}