light-openid/src/time_utils.rs

20 lines
357 B
Rust
Raw Normal View History

use std::time::{SystemTime, UNIX_EPOCH};
/// Get current time since epoch, in seconds
pub fn time() -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs()
}
#[cfg(test)]
mod test {
use crate::time_utils::time;
#[test]
fn time_is_recent_enough() {
assert!(time() > 1682750570);
}
}