pub struct ParseDate(/* private fields */);Expand description
A Parse date. Millisecond precision, UTC.
Precision is truncated to milliseconds on construction rather than at serialization, so that
two values that will serialize identically also compare equal. Doing it the other way round
makes a == b disagree with encode(a) == encode(b), which is the kind of thing that
produces an intermittent conformance failure.
Implementations§
Source§impl ParseDate
impl ParseDate
Sourcepub fn from_datetime(dt: DateTime<Utc>) -> Self
pub fn from_datetime(dt: DateTime<Utc>) -> Self
Truncates sub-millisecond precision.
Total by construction. The millisecond count came from a DateTime, so reconstructing
one from it cannot fail, but this is a request path and “cannot fail” is not a reason to
write a panic. Falling back to the untruncated value degrades precision on a date no
client can construct, which is a strictly better failure than taking down a worker.
pub fn now() -> Self
pub fn timestamp_millis(&self) -> i64
pub fn as_datetime(&self) -> DateTime<Utc>
Sourcepub fn to_iso(&self) -> String
pub fn to_iso(&self) -> String
The ISO form Parse emits: exactly three fractional digits, Z, never +00:00.
Sourcepub fn parse_iso(s: &str) -> Result<Self, ParseError>
pub fn parse_iso(s: &str) -> Result<Self, ParseError>
Parse an ISO 8601 string.
Deliberately permissive on input and strict on output, which matches Node: new Date(s)
accepts offsets and varying fractional precision, and toISOString() always emits
millisecond Z. So a value read from a database written by another client may carry an
offset, and it must normalize rather than fail.
Trait Implementations§
impl Copy for ParseDate
impl Eq for ParseDate
Source§impl Ord for ParseDate
impl Ord for ParseDate
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for ParseDate
impl PartialOrd for ParseDate
impl StructuralPartialEq for ParseDate
Auto Trait Implementations§
impl Freeze for ParseDate
impl RefUnwindSafe for ParseDate
impl Send for ParseDate
impl Sync for ParseDate
impl Unpin for ParseDate
impl UnsafeUnpin for ParseDate
impl UnwindSafe for ParseDate
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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§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.