Struct cap_std::time::SystemTime
source · pub struct SystemTime { /* private fields */ }
Expand description
A measurement of the system clock, useful for talking to external entities like the file system or other processes.
This corresponds to std::time::SystemTime
.
This SystemTime
has no now
, elapsed
methods. To obtain the current
time or measure the duration to the current time, first obtain a
SystemClock
, and then call SystemClock::now
or
SystemClock::elapsed
instead. The UNIX_EPOCH
constant is at
SystemClock::UNIX_EPOCH
.
Similar to the filetime
crate, when
RUSTFLAGS=--cfg emulate_second_only_system
is set, SystemTime
will
round times from the operating system down to the second. This emulates
the behavior of some file systems, mostly
HFS, allowing debugging on other hardware.
Implementations
sourceimpl SystemTime
impl SystemTime
sourcepub fn from_std(std: SystemTime) -> SystemTime
pub fn from_std(std: SystemTime) -> SystemTime
Constructs a new instance of Self
from the given
std::time::SystemTime
.
sourcepub const fn into_std(self) -> SystemTime
pub const fn into_std(self) -> SystemTime
Constructs a new instance of std::time::SystemTime
from the given
Self
.
sourcepub fn duration_since(
&self,
earlier: SystemTime
) -> Result<Duration, SystemTimeError>
pub fn duration_since(
&self,
earlier: SystemTime
) -> Result<Duration, SystemTimeError>
Returns the amount of time elapsed from another instant to this one.
This corresponds to std::time::SystemTime::duration_since
.
sourcepub fn checked_add(&self, duration: Duration) -> Option<SystemTime>
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.
This corresponds to std::time::SystemTime::checked_add
.
sourcepub fn checked_sub(&self, duration: Duration) -> Option<SystemTime>
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.
This corresponds to std::time::SystemTime::checked_sub
.
Trait Implementations
sourceimpl Add<Duration> for SystemTime
impl Add<Duration> for SystemTime
sourcefn add(self, dur: Duration) -> SystemTime
fn add(self, dur: Duration) -> SystemTime
Panics
This function may panic if the resulting point in time cannot be
represented by the underlying data structure. See
SystemTime::checked_add
for a version without panic.
type Output = SystemTime
type Output = SystemTime
+
operator.sourceimpl AddAssign<Duration> for SystemTime
impl AddAssign<Duration> for SystemTime
sourcefn add_assign(&mut self, other: Duration)
fn add_assign(&mut self, other: Duration)
+=
operation. Read moresourceimpl Clone for SystemTime
impl Clone for SystemTime
sourcefn clone(&self) -> SystemTime
fn clone(&self) -> SystemTime
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for SystemTime
impl Debug for SystemTime
sourceimpl Hash for SystemTime
impl Hash for SystemTime
sourceimpl Ord for SystemTime
impl Ord for SystemTime
sourcefn cmp(&self, other: &SystemTime) -> Ordering
fn cmp(&self, other: &SystemTime) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
sourceimpl PartialEq<SystemTime> for SystemTime
impl PartialEq<SystemTime> for SystemTime
sourcefn eq(&self, other: &SystemTime) -> bool
fn eq(&self, other: &SystemTime) -> bool
sourceimpl PartialOrd<SystemTime> for SystemTime
impl PartialOrd<SystemTime> for SystemTime
sourcefn partial_cmp(&self, other: &SystemTime) -> Option<Ordering>
fn partial_cmp(&self, other: &SystemTime) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresourceimpl Sub<Duration> for SystemTime
impl Sub<Duration> for SystemTime
type Output = SystemTime
type Output = SystemTime
-
operator.sourcefn sub(self, dur: Duration) -> SystemTime
fn sub(self, dur: Duration) -> SystemTime
-
operation. Read moresourceimpl SubAssign<Duration> for SystemTime
impl SubAssign<Duration> for SystemTime
sourcefn sub_assign(&mut self, other: Duration)
fn sub_assign(&mut self, other: Duration)
-=
operation. Read more