pub struct Timestamp {
pub seconds: i64,
pub nanosecond: u32,
}Expand description
An instant in time.
This is a well-known extension type (see ext) for
points in time independent of a time zone, such as Unix timestamps. It
holds the time since the Unix epoch (1970-01-01T00:00:00Z), ignoring
leap seconds. The nanoseconds are always positive: -0.5 seconds are
seconds: -1 and nanosecond: 500_000_000.
The fallback is the RFC 3339 representation in UTC as string. Instants
outside of the years 0 to 9999 are written with an expanded year as in
ISO 8601 (+10000-01-01T00:00:00Z).
use deser::ext::Timestamp;
let ts = Timestamp { seconds: 296638320, nanosecond: 0 };
assert_eq!(ts.to_string(), "1979-05-27T07:32:00Z");
assert_eq!("1979-05-27T00:32:00-07:00".parse::<Timestamp>().unwrap(), ts);std::time::SystemTime serializes as Timestamp, as do the
timestamp types of jiff, chrono and time with the respective
features.
Fields§
§seconds: i64The seconds since the Unix epoch.
nanosecond: u32The fraction of the second in nanoseconds (0 to 999_999_999).
Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub fn as_secs_f64(&self) -> f64
pub fn as_secs_f64(&self) -> f64
Returns the time since the epoch in seconds as float.
Sourcepub fn to_datetime(&self) -> Option<Datetime>
pub fn to_datetime(&self) -> Option<Datetime>
Converts the timestamp into an offset date-time in UTC.
Returns None if the year is outside of 0 to 9999.
Trait Implementations§
impl Copy for Timestamp
Source§impl<'de> Deserialize<'de> for Timestamp
impl<'de> Deserialize<'de> for Timestamp
Source§fn deserialize_atom(
slot: &mut Slot<Self>,
atom: Atom<'_>,
state: &mut State,
) -> Result<(), Error>
fn deserialize_atom( slot: &mut Slot<Self>, atom: Atom<'_>, state: &mut State, ) -> Result<(), Error>
Source§fn expecting() -> Cow<'static, str>
fn expecting() -> Cow<'static, str>
Source§fn deserialize_into<'out>(
out: &'out mut Option<T>,
state: &mut State,
) -> SinkHandle<'out, 'de>
fn deserialize_into<'out>( out: &'out mut Option<T>, state: &mut State, ) -> SinkHandle<'out, 'de>
Source§fn deserialize_borrowed_atom(
slot: &mut Slot<T, Self>,
atom: Atom<'de>,
state: &mut State,
) -> Result<(), Error>
fn deserialize_borrowed_atom( slot: &mut Slot<T, Self>, atom: Atom<'de>, state: &mut State, ) -> Result<(), Error>
Source§fn describe_type(d: &mut dyn Describe)
fn describe_type(d: &mut dyn Describe)
Source§fn initial_value() -> Option<T>
fn initial_value() -> Option<T>
Source§fn deserialize_update<'out>(
value: &'out mut T,
state: &mut State,
) -> SinkHandle<'out, 'de>
fn deserialize_update<'out>( value: &'out mut T, state: &mut State, ) -> SinkHandle<'out, 'de>
impl Eq for Timestamp
Source§impl Ord for Timestamp
impl Ord for Timestamp
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
Source§impl Serialize for Timestamp
impl Serialize for Timestamp
Source§fn serialize<'a>(value: &'a Self, _state: &mut State) -> Result<Emit<'a>, Error>
fn serialize<'a>(value: &'a Self, _state: &mut State) -> Result<Emit<'a>, Error>
Source§fn finish(value: &T, state: &mut State) -> Result<(), Error>
fn finish(value: &T, state: &mut State) -> Result<(), Error>
Source§fn container_shape(value: &T) -> ContainerShape
fn container_shape(value: &T) -> ContainerShape
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> BorrowedExtension for Twhere
T: Extension,
impl<T> BorrowedExtension for Twhere
T: Extension,
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
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<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.