pub struct Timestamp(/* private fields */);Expand description
A timestamp representing a point in time.
Internally stored as microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). This provides microsecond precision and can represent dates from roughly 290,000 BCE to 290,000 CE.
Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub const fn from_micros(micros: i64) -> Self
pub const fn from_micros(micros: i64) -> Self
Creates a timestamp from microseconds since the Unix epoch.
Sourcepub const fn from_millis(millis: i64) -> Self
pub const fn from_millis(millis: i64) -> Self
Creates a timestamp from milliseconds since the Unix epoch.
Sourcepub const fn from_secs(secs: i64) -> Self
pub const fn from_secs(secs: i64) -> Self
Creates a timestamp from seconds since the Unix epoch.
Sourcepub const fn as_micros(&self) -> i64
pub const fn as_micros(&self) -> i64
Returns the timestamp as microseconds since the Unix epoch.
Sourcepub const fn as_millis(&self) -> i64
pub const fn as_millis(&self) -> i64
Returns the timestamp as milliseconds since the Unix epoch.
Sourcepub fn as_system_time(&self) -> Option<SystemTime>
pub fn as_system_time(&self) -> Option<SystemTime>
Returns the timestamp as a SystemTime, if it’s within the representable range.
Sourcepub const fn add_micros(self, micros: i64) -> Self
pub const fn add_micros(self, micros: i64) -> Self
Adds a duration to this timestamp.
Sourcepub const fn sub_micros(self, micros: i64) -> Self
pub const fn sub_micros(self, micros: i64) -> Self
Subtracts a duration from this timestamp.
Sourcepub const fn duration_since(self, other: Self) -> i64
pub const fn duration_since(self, other: Self) -> i64
Returns the duration between this timestamp and another.
Returns a positive value if other is before self, negative otherwise.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Timestamp
impl<'de> Deserialize<'de> for Timestamp
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>,
Source§impl Ord for Timestamp
impl Ord for Timestamp
Source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
Source§impl TryFrom<SystemTime> for Timestamp
impl TryFrom<SystemTime> for Timestamp
impl Copy for Timestamp
impl Eq for Timestamp
impl StructuralPartialEq for Timestamp
Auto Trait Implementations§
impl Freeze for Timestamp
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnwindSafe for Timestamp
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.