Struct compact_time::Time
source · pub struct Time(/* private fields */);Expand description
A time value with nanosecond precision.
Values range from 1970-01-01 00:00:00 to 2514-05-30 01:53:03.
Implementations§
source§impl Time
impl Time
sourcepub const fn new(seconds: u64, nanos: u32) -> Self
pub const fn new(seconds: u64, nanos: u32) -> Self
Create a new time value.
Panics
This method asserts that seconds do not exceed 2^34 and that nanoseconds are less than 10^9.
sourcepub const fn try_new(seconds: u64, nanos: u32) -> Result<Self, OutOfRange>
pub const fn try_new(seconds: u64, nanos: u32) -> Result<Self, OutOfRange>
Try to create a new time value.
sourcepub fn try_now() -> Result<Self, OutOfRange>
pub fn try_now() -> Result<Self, OutOfRange>
Get the current system time.
May fail if the reported time is before 1970-01-01 00:00:00.
sourcepub fn coarse() -> Self
pub fn coarse() -> Self
Get the current system time using CLOCK_REALTIME_COARSE.
This is faster but less precise than the Self::now.
Panics
If the reported time is out of bounds.
sourcepub fn try_coarse() -> Result<Self, OutOfRange>
pub fn try_coarse() -> Result<Self, OutOfRange>
Get the current system time using CLOCK_REALTIME_COARSE.
This is faster but less precise than the Self::now.
sourcepub const fn try_from_seconds(s: u64) -> Result<Self, OutOfRange>
pub const fn try_from_seconds(s: u64) -> Result<Self, OutOfRange>
Contruct a time value from the given seconds.
sourcepub fn from_seconds(s: u64) -> Self
pub fn from_seconds(s: u64) -> Self
pub const fn seconds(self) -> u64
pub const fn second_nanos(self) -> u32
pub fn add_nanos(self, n: u32) -> Self
pub fn add_seconds(self, s: u64) -> Self
pub fn add_minutes(self, h: u32) -> Self
pub fn add_hours(self, h: u32) -> Self
pub fn add_days(self, d: u16) -> Self
pub fn add_nanos_checked(self, n: u32) -> Option<Self>
pub fn add_seconds_checked(self, s: u64) -> Option<Self>
pub fn add_minutes_checked(self, h: u32) -> Option<Self>
pub fn add_hours_checked(self, h: u32) -> Option<Self>
pub fn add_days_checked(self, d: u16) -> Option<Self>
pub fn sub_seconds(self, s: u64) -> Self
pub fn sub_seconds_checked(self, s: u64) -> Option<Self>
pub const fn to_duration(self) -> Duration
pub fn duration_since(self, earlier: Self) -> Option<Duration>
pub fn to_utc_string(self) -> Option<String>
Trait Implementations§
source§impl<'de> Deserialize<'de> for Time
impl<'de> Deserialize<'de> for Time
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Ord for Time
impl Ord for Time
source§impl PartialEq for Time
impl PartialEq for Time
source§impl PartialOrd for Time
impl PartialOrd for Time
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl Copy for Time
impl Eq for Time
impl StructuralEq for Time
impl StructuralPartialEq for Time
Auto Trait Implementations§
impl RefUnwindSafe for Time
impl Send for Time
impl Sync for Time
impl Unpin for Time
impl UnwindSafe for Time
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more