Struct concordium_std::Timestamp
source · [−]#[repr(transparent)]pub struct Timestamp { /* private fields */ }
Expand description
Timestamp represented as milliseconds since unix epoch.
Timestamps from before January 1st 1970 at 00:00 are not supported.
Implementations
sourceimpl Timestamp
impl Timestamp
sourcepub fn from_timestamp_millis(milliseconds: u64) -> Timestamp
pub fn from_timestamp_millis(milliseconds: u64) -> Timestamp
Construct timestamp from milliseconds since unix epoch.
sourcepub fn timestamp_millis(&self) -> u64
pub fn timestamp_millis(&self) -> u64
Milliseconds since the UNIX epoch.
sourcepub fn checked_add(self, duration: Duration) -> Option<Timestamp>
pub fn checked_add(self, duration: Duration) -> Option<Timestamp>
Add duration to the timestamp. Returns None
if the resulting timestamp
is not representable, i.e., too far in the future.
sourcepub fn checked_sub(self, duration: Duration) -> Option<Timestamp>
pub fn checked_sub(self, duration: Duration) -> Option<Timestamp>
Subtract duration from the timestamp. Returns None
instead of
overflowing if the resulting timestamp would be before the Unix
epoch.
sourcepub fn duration_between(self, other: Timestamp) -> Duration
pub fn duration_between(self, other: Timestamp) -> Duration
Compute the duration between the self and another timestamp. The duration is always positive, and is the difference between the the more recent timestamp and the one further in the past.
sourcepub fn duration_since(self, before: Timestamp) -> Option<Duration>
pub fn duration_since(self, before: Timestamp) -> Option<Duration>
Compute duration since a given timestamp. Returns None
if given time
is in the future compared to self.
Trait Implementations
sourceimpl Ord for Timestamp
impl Ord for Timestamp
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<Timestamp> for Timestamp
impl PartialEq<Timestamp> for Timestamp
sourceimpl PartialOrd<Timestamp> for Timestamp
impl PartialOrd<Timestamp> for Timestamp
sourcefn partial_cmp(&self, other: &Timestamp) -> Option<Ordering>
fn partial_cmp(&self, other: &Timestamp) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn 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 more
impl Copy for Timestamp
impl Eq for Timestamp
impl StructuralEq for Timestamp
impl StructuralPartialEq for Timestamp
Auto Trait Implementations
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnwindSafe for Timestamp
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more