Skip to main content

NdaSystemTimeDeprecatedSyntax

Type Alias NdaSystemTimeDeprecatedSyntax 

Source
pub type NdaSystemTimeDeprecatedSyntax = Iso8601TimeSp;
Expand description

Date and time in deprecated ISO8601-with-space separate arguments syntax

Eg dir-key-published in a dir auth key cert.

Aliased Type§

pub struct NdaSystemTimeDeprecatedSyntax(pub SystemTime);

Tuple Fields§

§0: SystemTime

Methods from Deref<Target = SystemTime>§

1.8.0 · Source

pub fn duration_since( &self, earlier: SystemTime, ) -> Result<Duration, SystemTimeError>

Returns the amount of time elapsed from an earlier point in time.

This function may fail because measurements taken earlier are not guaranteed to always be before later measurements (due to anomalies such as the system clock being adjusted either forwards or backwards). Instant can be used to measure elapsed time without this risk of failure.

If successful, Ok(Duration) is returned where the duration represents the amount of time elapsed from the specified measurement to this one.

Returns an Err if earlier is later than self, and the error contains how far from self the time is.

§Examples
use std::time::SystemTime;

let sys_time = SystemTime::now();
let new_sys_time = SystemTime::now();
let difference = new_sys_time.duration_since(sys_time)
    .expect("Clock may have gone backwards");
println!("{difference:?}");
1.8.0 · Source

pub fn elapsed(&self) -> Result<Duration, SystemTimeError>

Returns the difference from this system time to the current clock time.

This function may fail as the underlying system clock is susceptible to drift and updates (e.g., the system clock could go backwards), so this function might not always succeed. If successful, Ok(Duration) is returned where the duration represents the amount of time elapsed from this time measurement to the current time.

To measure elapsed time reliably, use Instant instead.

Returns an Err if self is later than the current system time, and the error contains how far from the current system time self is.

§Examples
use std::thread::sleep;
use std::time::{Duration, SystemTime};

let sys_time = SystemTime::now();
let one_sec = Duration::from_secs(1);
sleep(one_sec);
assert!(sys_time.elapsed().unwrap() >= one_sec);
1.34.0 · Source

pub fn checked_add(&self, duration: Duration) -> Option<SystemTime>

Returns Some(t) where t is the time self + duration if t can be represented as SystemTime (which means it’s inside the bounds of the underlying data structure), None otherwise.

In the case that the duration is smaller than the time precision of the operating system, Some(self) will be returned.

1.34.0 · Source

pub fn checked_sub(&self, duration: Duration) -> Option<SystemTime>

Returns Some(t) where t is the time self - duration if t can be represented as SystemTime (which means it’s inside the bounds of the underlying data structure), None otherwise.

In the case that the duration is smaller than the time precision of the operating system, Some(self) will be returned.

Source

pub fn saturating_add(&self, duration: Duration) -> SystemTime

🔬This is a nightly-only experimental API. (time_saturating_systemtime)

Saturating SystemTime addition, computing self + duration, returning SystemTime::MAX if overflow occurred.

In the case that the duration is smaller than the time precision of the operating system, self will be returned.

Source

pub fn saturating_sub(&self, duration: Duration) -> SystemTime

🔬This is a nightly-only experimental API. (time_saturating_systemtime)

Saturating SystemTime subtraction, computing self - duration, returning SystemTime::MIN if overflow occurred.

In the case that the duration is smaller than the time precision of the operating system, self will be returned.

Source

pub fn saturating_duration_since(&self, earlier: SystemTime) -> Duration

🔬This is a nightly-only experimental API. (time_saturating_systemtime)

Saturating computation of time elapsed from an earlier point in time, returning Duration::ZERO in the case that earlier is later or equal to self.

§Examples
#![feature(time_saturating_systemtime)]
use std::time::{Duration, SystemTime};

let now = SystemTime::now();
let prev = now.saturating_sub(Duration::new(1, 0));

// now - prev should return non-zero.
assert_eq!(now.saturating_duration_since(prev), Duration::new(1, 0));
assert!(now.duration_since(prev).is_ok());

// prev - now should return zero (and fail with the non-saturating).
assert_eq!(prev.saturating_duration_since(now), Duration::ZERO);
assert!(prev.duration_since(now).is_err());

// now - now should return zero (and work with the non-saturating).
assert_eq!(now.saturating_duration_since(now), Duration::ZERO);
assert!(now.duration_since(now).is_ok());

Trait Implementations§