Struct UnixTimestamp
pub struct UnixTimestamp(/* private fields */);Expand description
A unix timestamp (full seconds elapsed since 1970-01-01 00:00 UTC).
Implementations§
§impl UnixTimestamp
impl UnixTimestamp
pub const fn from_secs(secs: u64) -> UnixTimestamp
pub const fn from_secs(secs: u64) -> UnixTimestamp
Creates a unix timestamp from the given number of seconds.
pub fn from_system(time: SystemTime) -> UnixTimestamp
pub fn from_system(time: SystemTime) -> UnixTimestamp
Creates a unix timestamp from the given system time.
pub fn from_datetime(
date_time: DateTime<impl TimeZone>,
) -> Option<UnixTimestamp>
pub fn from_datetime( date_time: DateTime<impl TimeZone>, ) -> Option<UnixTimestamp>
Creates a unix timestamp from the given chrono DateTime.
Returns Some if this is a valid date time starting with 1970-01-01 00:00 UTC. If the date
lies before the UNIX epoch, this function returns None.
pub fn from_instant(instant: Instant) -> UnixTimestamp
pub fn from_instant(instant: Instant) -> UnixTimestamp
Converts the given Instant into a UNIX timestamp.
This is done by comparing the Instant with the current system time. Note that the system
time is subject to skew, so subsequent calls to from_instant may return different values.
pub fn now() -> UnixTimestamp
pub fn now() -> UnixTimestamp
Returns the current timestamp.
pub fn as_nanos(self) -> u64
pub fn as_nanos(self) -> u64
Returns the number of nanoseconds since the UNIX epoch start. Precision limited to seconds.
pub fn as_datetime(self) -> Option<DateTime<Utc>>
pub fn as_datetime(self) -> Option<DateTime<Utc>>
Returns the timestamp as chrono datetime.
Trait Implementations§
§impl Add<Duration> for UnixTimestamp
Adds whole seconds of the given duration to the timestamp.
impl Add<Duration> for UnixTimestamp
Adds whole seconds of the given duration to the timestamp.
§impl Clone for UnixTimestamp
impl Clone for UnixTimestamp
§fn clone(&self) -> UnixTimestamp
fn clone(&self) -> UnixTimestamp
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for UnixTimestamp
impl Debug for UnixTimestamp
§impl<'de> Deserialize<'de> for UnixTimestamp
impl<'de> Deserialize<'de> for UnixTimestamp
§fn deserialize<D>(
deserializer: D,
) -> Result<UnixTimestamp, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<UnixTimestamp, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl Display for UnixTimestamp
impl Display for UnixTimestamp
§impl FromStr for UnixTimestamp
impl FromStr for UnixTimestamp
§impl Hash for UnixTimestamp
impl Hash for UnixTimestamp
§impl Ord for UnixTimestamp
impl Ord for UnixTimestamp
§impl PartialEq for UnixTimestamp
impl PartialEq for UnixTimestamp
§impl PartialOrd for UnixTimestamp
impl PartialOrd for UnixTimestamp
§impl Serialize for UnixTimestamp
impl Serialize for UnixTimestamp
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
§impl Sub for UnixTimestamp
impl Sub for UnixTimestamp
§fn sub(self, rhs: UnixTimestamp) -> <UnixTimestamp as Sub>::Output
fn sub(self, rhs: UnixTimestamp) -> <UnixTimestamp as Sub>::Output
- operation. Read moreimpl Copy for UnixTimestamp
impl Eq for UnixTimestamp
impl StructuralPartialEq for UnixTimestamp
Auto Trait Implementations§
impl Freeze for UnixTimestamp
impl RefUnwindSafe for UnixTimestamp
impl Send for UnixTimestamp
impl Sync for UnixTimestamp
impl Unpin for UnixTimestamp
impl UnwindSafe for UnixTimestamp
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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.