pub struct SystemTime(_);
A measurement of the system clock, useful for talking to
external entities like the file system or other processes.
Distinct from the Instant
type, this time measurement is not
monotonic. This means that you can save a file to the file system, then
save another file to the file system, and the second file has a
SystemTime
measurement earlier than the first. In other words, an
operation that happens after another operation in real time may have an
earlier SystemTime
!
Consequently, comparing two SystemTime
instances to learn about the
duration between them returns a Result
instead of an infallible Duration
to indicate that this sort of time drift may happen and needs to be handled.
Although a SystemTime
cannot be directly inspected, the UNIX_EPOCH
constant is provided in this module as an anchor in time to learn
information about a SystemTime
. By calculating the duration from this
fixed point in time, a SystemTime
can be converted to a human-readable time,
or perhaps some other string representation.
The size of a SystemTime
struct may vary depending on the target operating
system.
UNIX_EPOCH: SystemTime = UNIX_EPOCH
An anchor in time which can be used to create new SystemTime
instances or
learn about where in time a SystemTime
lies.
This constant is defined to be "1970-01-01 00:00:00 UTC" on all systems with
respect to the system clock. Using duration_since
on an existing
SystemTime
instance can tell how far away from this point in time a
measurement lies, and using UNIX_EPOCH + duration
can be used to create a
SystemTime
instance to represent another fixed point in time.
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).
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.
Performs copy-assignment from source
. Read more
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self | 1.21.0 [src] |
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self | 1.21.0 [src] |
Compares and returns the minimum of two values. Read more
Feeds this value into the given [Hasher
]. Read more
Feeds a slice of this type into the given [Hasher
]. Read more
The resulting type after applying the +
operator.
Performs the +
operation.
Performs the +=
operation.
The resulting type after applying the -
operator.
Performs the -
operation.
Performs the -=
operation.
Formats the value using the given formatter. Read more
Returns the system time corresponding to "now".
Returns the amount of time elapsed since this system time was created.
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 may 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.
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.