Struct concordium_std::Timestamp
source · #[repr(transparent)]pub struct Timestamp {
pub millis: u64,
}
Expand description
Timestamp represented as milliseconds since unix epoch.
Timestamps from before January 1st 1970 at 00:00 are not supported.
Fields§
§millis: u64
Milliseconds since unix epoch.
Implementations§
source§impl Timestamp
impl Timestamp
sourcepub const fn from_timestamp_millis(millis: u64) -> Timestamp
pub const fn from_timestamp_millis(millis: u64) -> Timestamp
Construct timestamp from milliseconds since unix epoch.
sourcepub const fn timestamp_millis(&self) -> u64
pub const 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§
source§impl Ord for Timestamp
impl Ord for Timestamp
source§impl PartialEq for Timestamp
impl PartialEq for Timestamp
source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more