pub struct Timestamp(/* private fields */);Expand description
A point in time, with nanosecond precision.
Write it with Timestamp::format, or parse it from RFC 3339 with str::parse. It can represent any time from
the year -9999 to 9999-12-30T22:00:00Z.
Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub const UNIX_EPOCH: Self
pub const UNIX_EPOCH: Self
The Unix epoch, 1970-01-01T00:00:00Z.
Sourcepub fn now() -> Result<Self, GenericError>
pub fn now() -> Result<Self, GenericError>
Gets the current time.
§Errors
If the system clock is outside of the range that Timestamp supports, an error is returned.
Sourcepub fn from_unix_seconds(seconds: i64) -> Option<Self>
pub fn from_unix_seconds(seconds: i64) -> Option<Self>
Creates a Timestamp from a number of seconds since the Unix epoch, or None if it’s out of range.
Sourcepub fn from_unix_millis(millis: i64) -> Option<Self>
pub fn from_unix_millis(millis: i64) -> Option<Self>
Creates a Timestamp from a number of milliseconds since the Unix epoch, or None if it’s out of range.
Sourcepub fn from_unix_nanos(nanos: i128) -> Option<Self>
pub fn from_unix_nanos(nanos: i128) -> Option<Self>
Creates a Timestamp from a number of nanoseconds since the Unix epoch, or None if it’s out of range.
Sourcepub fn as_unix_millis(self) -> i64
pub fn as_unix_millis(self) -> i64
Returns the number of whole milliseconds since the Unix epoch, rounded down to the earlier millisecond.
Sourcepub fn as_unix_nanos(self) -> i128
pub fn as_unix_nanos(self) -> i128
Returns the number of nanoseconds since the Unix epoch.
Sourcepub fn whole_seconds_since(self, earlier: Self) -> i64
pub fn whole_seconds_since(self, earlier: Self) -> i64
Returns the number of whole seconds from earlier to this timestamp, rounded toward zero.
The result is negative if earlier is actually later, such as when the system clock went backwards.
Sourcepub fn format(self, format: TimestampFormat<'_>) -> FormattedTimestamp<'_>
pub fn format(self, format: TimestampFormat<'_>) -> FormattedTimestamp<'_>
Returns a value that writes this timestamp in the given format.
Trait Implementations§
Source§impl Ord for Timestamp
impl Ord for Timestamp
Source§impl PartialOrd for Timestamp
impl PartialOrd 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 UnsafeUnpin 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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Track for T
impl<T> Track for T
Source§fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self> ⓘ
fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self> ⓘ
Tracked wrapper. Read more