trifid/trifid-api/src/timers.rs

9 lines
326 B
Rust
Raw Normal View History

2023-04-02 19:25:52 +00:00
use std::time::{Duration, SystemTime, UNIX_EPOCH};
pub fn expires_in_seconds(seconds: u64) -> u64 {
(SystemTime::now() + Duration::from_secs(seconds)).duration_since(UNIX_EPOCH).expect("Time went backwards").as_secs()
}
pub fn expired(time: u64) -> bool {
UNIX_EPOCH + Duration::from_secs(time) > SystemTime::now()
}