pub struct DateTime(/* private fields */);Expand description
Helper for validated date/time string construction.
Wraps an RFC 3339 (an ISO 8601 profile) UTC string suitable
for CBOR tag 0. The string is validated on creation: the date
must be within 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z,
and follow RFC 3339 section 5.6 layout.
Whole-second timestamps omit the fractional part. Sub-second timestamps include only the necessary digits (1-9, no trailing zeros).
CBOR::Core references section 5.6 of RFC3339, which allows leap seconds (second == 60). So we accept leap seconds and validate, if the date is one of the currently known 27 leap second dates.
However, trying to convert a date/time value containing a
leap second to SystemTime will fail with Err(InvalidEncoding).
Implements TryFrom<SystemTime> and TryFrom<&str>, so that
Value::date_time can accept both through a single
TryInto<DateTime> bound.
Trait Implementations§
Source§impl Ord for DateTime
impl Ord for DateTime
Source§impl PartialOrd for DateTime
impl PartialOrd for DateTime
Source§impl<Tz: TimeZone> TryFrom<&DateTime<Tz>> for DateTime
Available on crate feature chrono only.
impl<Tz: TimeZone> TryFrom<&DateTime<Tz>> for DateTime
chrono only.Source§impl TryFrom<&OffsetDateTime> for DateTime
Available on crate feature time only.
impl TryFrom<&OffsetDateTime> for DateTime
time only.Source§impl TryFrom<&UtcDateTime> for DateTime
Available on crate feature time only.
impl TryFrom<&UtcDateTime> for DateTime
time only.Source§impl<Tz: TimeZone> TryFrom<DateTime<Tz>> for DateTime
Available on crate feature chrono only.
impl<Tz: TimeZone> TryFrom<DateTime<Tz>> for DateTime
chrono only.Source§impl TryFrom<OffsetDateTime> for DateTime
Available on crate feature time only.
impl TryFrom<OffsetDateTime> for DateTime
time only.Source§fn try_from(dt: OffsetDateTime) -> Result<Self>
fn try_from(dt: OffsetDateTime) -> Result<Self>
Converts a time::OffsetDateTime to a CBOR date/time string (tag 0).
Whole-second timestamps omit the fractional part and sub-second timestamps include only the necessary digits.
Source§impl TryFrom<SystemTime> for DateTime
impl TryFrom<SystemTime> for DateTime
Source§impl TryFrom<UtcDateTime> for DateTime
Available on crate feature time only.
impl TryFrom<UtcDateTime> for DateTime
time only.Source§fn try_from(dt: UtcDateTime) -> Result<Self>
fn try_from(dt: UtcDateTime) -> Result<Self>
Converts a time::UtcDateTime to a CBOR date/time string (tag 0).
Whole-second timestamps omit the fractional part and sub-second timestamps include only the necessary digits.