#[non_exhaustive]pub struct NdbDateTime {
pub micros: i64,
}Expand description
Microseconds-precision UTC timestamp.
Stores microseconds since Unix epoch as i64. Supports dates from ~292,000 years BCE to ~292,000 years CE.
String format: ISO 8601 "2024-03-15T10:30:00.000000Z".
#[non_exhaustive] — a timezone offset field may be added when
named-timezone support is introduced.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.micros: i64Microseconds since Unix epoch (1970-01-01T00:00:00Z).
Implementations§
Source§impl NdbDateTime
impl NdbDateTime
Sourcepub fn from_micros(micros: i64) -> Self
pub fn from_micros(micros: i64) -> Self
Create from microseconds since epoch.
Sourcepub fn from_millis(millis: i64) -> Result<Self, NdbDateTimeError>
pub fn from_millis(millis: i64) -> Result<Self, NdbDateTimeError>
Create from milliseconds since epoch.
Returns Err if millis * 1_000 overflows i64.
Sourcepub fn from_secs(secs: i64) -> Result<Self, NdbDateTimeError>
pub fn from_secs(secs: i64) -> Result<Self, NdbDateTimeError>
Create from seconds since epoch.
Returns Err if secs * 1_000_000 overflows i64.
Sourcepub fn now() -> Self
pub fn now() -> Self
Current UTC time.
Converts SystemTime microseconds (u128) to i64. Saturates at
i64::MAX (year ~292,277 CE) rather than wrapping — clocks that far
in the future simply report the maximum representable timestamp.
Sourcepub fn components(&self) -> DateTimeComponents
pub fn components(&self) -> DateTimeComponents
Extract year, month, day, hour, minute, second components.
Sourcepub fn to_iso8601(&self) -> String
pub fn to_iso8601(&self) -> String
Format as ISO 8601 string: "2024-03-15T10:30:00.000000Z".
Sourcepub fn parse(s: &str) -> Option<Self>
pub fn parse(s: &str) -> Option<Self>
Parse from ISO 8601 string (basic subset).
Supports: "2024-03-15T10:30:00Z", "2024-03-15T10:30:00.123456Z",
"2024-03-15" (midnight UTC).
Sourcepub fn add_duration(&self, d: NdbDuration) -> Result<Self, NdbDateTimeError>
pub fn add_duration(&self, d: NdbDuration) -> Result<Self, NdbDateTimeError>
Add a duration.
Returns Err if the result overflows i64.
Sourcepub fn sub_duration(&self, d: NdbDuration) -> Result<Self, NdbDateTimeError>
pub fn sub_duration(&self, d: NdbDuration) -> Result<Self, NdbDateTimeError>
Subtract a duration.
Returns Err if the result overflows i64.
Sourcepub fn duration_since(
&self,
other: &NdbDateTime,
) -> Result<NdbDuration, NdbDateTimeError>
pub fn duration_since( &self, other: &NdbDateTime, ) -> Result<NdbDuration, NdbDateTimeError>
Duration between two timestamps (self - other).
Returns Err if the result overflows i64.
Sourcepub fn unix_millis(&self) -> i64
pub fn unix_millis(&self) -> i64
Unix epoch milliseconds.
Trait Implementations§
Source§impl Clone for NdbDateTime
impl Clone for NdbDateTime
Source§fn clone(&self) -> NdbDateTime
fn clone(&self) -> NdbDateTime
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NdbDateTime
impl Debug for NdbDateTime
Source§impl<'de> Deserialize<'de> for NdbDateTime
impl<'de> Deserialize<'de> for NdbDateTime
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for NdbDateTime
impl Display for NdbDateTime
Source§impl From<NdbDateTime> for Value
impl From<NdbDateTime> for Value
Source§fn from(dt: NdbDateTime) -> Self
fn from(dt: NdbDateTime) -> Self
Source§impl<'__msgpack_de> FromMessagePack<'__msgpack_de> for NdbDateTime
impl<'__msgpack_de> FromMessagePack<'__msgpack_de> for NdbDateTime
Source§impl Hash for NdbDateTime
impl Hash for NdbDateTime
Source§impl Ord for NdbDateTime
impl Ord for NdbDateTime
Source§fn cmp(&self, other: &NdbDateTime) -> Ordering
fn cmp(&self, other: &NdbDateTime) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for NdbDateTime
impl PartialEq for NdbDateTime
Source§fn eq(&self, other: &NdbDateTime) -> bool
fn eq(&self, other: &NdbDateTime) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for NdbDateTime
impl PartialOrd for NdbDateTime
Source§impl Serialize for NdbDateTime
impl Serialize for NdbDateTime
Source§impl ToMessagePack for NdbDateTime
impl ToMessagePack for NdbDateTime
impl Copy for NdbDateTime
impl Eq for NdbDateTime
impl StructuralPartialEq for NdbDateTime
Auto Trait Implementations§
impl Freeze for NdbDateTime
impl RefUnwindSafe for NdbDateTime
impl Send for NdbDateTime
impl Sync for NdbDateTime
impl Unpin for NdbDateTime
impl UnsafeUnpin for NdbDateTime
impl UnwindSafe for NdbDateTime
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.