pub struct Datetime { /* private fields */ }Expand description
AT Protocol datetime (ISO 8601 with specific requirements)
Lexicon datetimes use ISO 8601 format with these requirements:
- Must include timezone (strongly prefer UTC with ‘Z’)
- Requires whole seconds precision minimum
- Supports millisecond and microsecond precision
- Uses uppercase ‘T’ to separate date and time
Examples: "1985-04-12T23:20:50.123Z", "2023-01-01T00:00:00+00:00"
The serialized form is preserved during parsing to ensure exact round-trip serialization.
Implementations§
Source§impl Datetime
impl Datetime
Sourcepub fn now() -> Self
pub fn now() -> Self
Returns a Datetime which corresponds to the current date and time in UTC.
The timestamp uses microsecond precision.
Sourcepub fn new(dt: DateTime<FixedOffset>) -> Self
pub fn new(dt: DateTime<FixedOffset>) -> Self
Constructs a new Lexicon timestamp.
The timestamp is rounded to microsecond precision.
Sourcepub fn raw_str(s: impl AsRef<str>) -> Self
pub fn raw_str(s: impl AsRef<str>) -> Self
Infallibly parses a new Lexicon timestamp from a compatible str reference
Panics if invalid. Use the fallible trait implementations or deserialize for input you cannot reasonably trust to be properly formatted.
Sourcepub fn timestamp(&self) -> i64
pub fn timestamp(&self) -> i64
Extracts the number of non-leap seconds since January 1, 1970 0:00:00 UTC (aka “UNIX timestamp”).
For full access to the underlying DateTime, use the AsRef<chrono::DateTime<chrono::FixedOffset>> implementation.
Sourcepub fn timestamp_millis(&self) -> i64
pub fn timestamp_millis(&self) -> i64
Extracts the number of non-leap-milliseconds since January 1, 1970 UTC.
For full access to the underlying DateTime, use the AsRef<chrono::DateTime<chrono::FixedOffset>> implementation.
Sourcepub fn timestamp_micros(&self) -> i64
pub fn timestamp_micros(&self) -> i64
Extracts the number of non-leap-microseconds since January 1, 1970 UTC.
For full access to the underlying DateTime, use the AsRef<chrono::DateTime<chrono::FixedOffset>> implementation.
Trait Implementations§
Source§impl AsRef<DateTime<FixedOffset>> for Datetime
impl AsRef<DateTime<FixedOffset>> for Datetime
Source§fn as_ref(&self) -> &DateTime<FixedOffset>
fn as_ref(&self) -> &DateTime<FixedOffset>
Source§impl<'de> Deserialize<'de> for Datetime
impl<'de> Deserialize<'de> for Datetime
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>,
impl Eq for Datetime
Source§impl From<DateTime<FixedOffset>> for Datetime
impl From<DateTime<FixedOffset>> for Datetime
Source§fn from(dt: DateTime<FixedOffset>) -> Self
fn from(dt: DateTime<FixedOffset>) -> Self
Source§impl IntoStatic for Datetime
impl IntoStatic for Datetime
Source§impl Ord for Datetime
impl Ord for Datetime
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 Datetime
impl PartialOrd for Datetime
Auto Trait Implementations§
impl Freeze for Datetime
impl RefUnwindSafe for Datetime
impl Send for Datetime
impl Sync for Datetime
impl Unpin for Datetime
impl UnsafeUnpin for Datetime
impl UnwindSafe for Datetime
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
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.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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.