pub struct Time { /* private fields */ }Expand description
One instant in real-life
It can hold any time between roughly 10^22 years before and after posix epoch.
Implementations§
Source§impl Time
impl Time
Sourcepub const POSIX_EPOCH: Time
pub const POSIX_EPOCH: Time
The posix epoch (1970-01-01T00:00:00 Gregorian UTC)
Sourcepub fn try_now() -> Result<TimeResult>
pub fn try_now() -> Result<TimeResult>
Return the current time as indicated by the system timezone
Note that this will panic in no-std environments if an alternative way of getting the time is not known for the platform.
Sourcepub fn now() -> Time
pub fn now() -> Time
Return the current time
If the system clock (as returned by Rust’s SystemTime::now()) is in a non-UTC
timezone mode, then this will return any one of the possible Times corresponding
to the time returned by the system clock. This should not happen anyway as Rust’s
SystemTime should return POSIX timestamps (so, UTC) even when the system clock
is set to local time, so there should be no issue in relying on this function.
Note that this will panic in no-std environments if an alternative way of getting the time is not known for the platform.
Sourcepub fn read<Tim: CalendarTime>(t: Tim) -> Result<TimeResult>
pub fn read<Tim: CalendarTime>(t: Tim) -> Result<TimeResult>
Read the current time from a given written time
Sourcepub fn write<Cal: Calendar>(&self, cal: Cal) -> Result<WrittenTime<Cal>>
pub fn write<Cal: Calendar>(&self, cal: Cal) -> Result<WrittenTime<Cal>>
Write the current time in a given calendar
Sourcepub const fn checked_add(&self, rhs: &Duration) -> Option<Time>
pub const fn checked_add(&self, rhs: &Duration) -> Option<Time>
Offset by a duration, returning None on (however unlikely) overflow
Sourcepub const fn checked_sub(&self, rhs: &Duration) -> Option<Time>
pub const fn checked_sub(&self, rhs: &Duration) -> Option<Time>
Offset by a duration, returning None on (however unlikely) overflow
Sourcepub fn duration_since(&self, rhs: &Time) -> Duration
pub fn duration_since(&self, rhs: &Time) -> Duration
Return the duration elapsed since the other point in time
Sourcepub fn checked_duration_since(&self, rhs: &Time) -> Option<Duration>
pub fn checked_duration_since(&self, rhs: &Time) -> Option<Duration>
Return the duration elapsed since the other point in time
Returns None on the (however unlikely) overflow
Trait Implementations§
Source§impl AddAssign<Duration> for Time
impl AddAssign<Duration> for Time
Source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+= operation. Read moreSource§impl Ord for Time
impl Ord for Time
Source§impl PartialOrd for Time
impl PartialOrd for Time
Source§impl SubAssign<Duration> for Time
impl SubAssign<Duration> for Time
Source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-= operation. Read more