mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2024-11-25 22:48:34 +00:00
add timepoint_from_now to complement timepoint_ago in utils
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
2ed0c267eb
commit
89b5c4ee1c
|
@ -34,7 +34,7 @@ pub use self::{
|
|||
stream::{IterStream, ReadyExt, Tools as StreamTools, TryReadyExt},
|
||||
string::{str_from_bytes, string_from_bytes},
|
||||
sys::available_parallelism,
|
||||
time::now_millis as millis_since_unix_epoch,
|
||||
time::{now_millis as millis_since_unix_epoch, timepoint_ago, timepoint_from_now},
|
||||
};
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -22,6 +22,13 @@ pub fn timepoint_ago(duration: Duration) -> Result<SystemTime> {
|
|||
.ok_or_else(|| err!(Arithmetic("Duration {duration:?} is too large")))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn timepoint_from_now(duration: Duration) -> Result<SystemTime> {
|
||||
SystemTime::now()
|
||||
.checked_add(duration)
|
||||
.ok_or_else(|| err!(Arithmetic("Duration {duration:?} is too large")))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn parse_duration(duration: &str) -> Result<Duration> {
|
||||
cyborgtime::parse_duration(duration)
|
||||
|
|
Loading…
Reference in a new issue