9 lines
326 B
Rust
9 lines
326 B
Rust
|
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()
|
||
|
}
|