light-openid/src/time_utils.rs
Pierre Hubert 394e29ae55
All checks were successful
continuous-integration/drone/push Build is passing
Develop first version (#1)
Create first version of the library

The code is mainly taken from

* https://gitea.communiquons.org/pierre/oidc-test-client
* https://gitea.communiquons.org/pierre/BasicOIDC

with little improvements.

Reviewed-on: #1
2023-04-29 07:49:35 +00:00

20 lines
357 B
Rust

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);
}
}