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 {
|
2023-04-03 01:11:27 +00:00
|
|
|
UNIX_EPOCH + Duration::from_secs(time) < SystemTime::now()
|
2023-04-02 19:25:52 +00:00
|
|
|
}
|