pub struct Datetime {
pub date: Option<Date>,
pub time: Option<Time>,
pub offset: Option<Offset>,
}Expand description
Re-exported from deser::ext for convenience.
A date, a time of the day, or both with an optional offset.
This is a well-known extension type (see ext) for the
date and time values of RFC 3339:
| Kind | date | time | offset |
|---|---|---|---|
offset date-time (1979-05-27T07:32:00Z) | Some | Some | Some |
local date-time (1979-05-27T07:32:00) | Some | Some | None |
local date (1979-05-27) | Some | None | None |
local time (07:32:00) | None | Some | None |
The fallback is the RFC 3339 representation as string.
Parsing is lenient: the separator between date and time can be T, t
or a space, Z can be lowercase and seconds can be omitted. Formatting
always produces RFC 3339. Digits of the fraction beyond nanoseconds are
truncated.
use deser::ext::Datetime;
let dt: Datetime = "1979-05-27 07:32:00.5-07:00".parse().unwrap();
assert_eq!(dt.to_string(), "1979-05-27T07:32:00.5-07:00");With the jiff, chrono and time features the date and time types of
these crates serialize as Datetime (or Timestamp).
Fields§
§date: Option<Date>The date. None for local times.
time: Option<Time>The time. None for local dates.
offset: Option<Offset>The offset. Only set for offset date-times.
Implementations§
Trait Implementations§
impl Copy for Datetime
Source§impl<'de> Deserialize<'de> for Datetime
impl<'de> Deserialize<'de> for Datetime
Source§fn deserialize_atom(
slot: &mut Slot<Datetime>,
atom: Atom<'_>,
state: &mut State,
) -> Result<(), Error>
fn deserialize_atom( slot: &mut Slot<Datetime>, atom: Atom<'_>, state: &mut State, ) -> Result<(), Error>
Deserializes an atom into the slot. Read more
Source§fn expecting() -> Cow<'static, str>
fn expecting() -> Cow<'static, str>
Returns what the value expects, for error messages. Read more
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>
Creates a sink that deserializes the value into the given slot. Read more
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>
Deserializes an atom that borrows from the data being deserialized
into the slot. Read more
Source§fn describe_type(d: &mut dyn Describe)
fn describe_type(d: &mut dyn Describe)
Describes the Rust shape of the type. Read more
Source§fn initial_value() -> Option<T>
fn initial_value() -> Option<T>
Provides the value of a missing struct field. Read more
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>
Creates a sink that updates an existing value. Read more
impl Eq for Datetime
Source§impl Serialize for Datetime
impl Serialize for Datetime
Source§fn serialize<'a>(
value: &'a Datetime,
_state: &mut State,
) -> Result<Emit<'a>, Error>
fn serialize<'a>( value: &'a Datetime, _state: &mut State, ) -> Result<Emit<'a>, Error>
Serializes the value.
Source§fn finish(value: &T, state: &mut State) -> Result<(), Error>
fn finish(value: &T, state: &mut State) -> Result<(), Error>
Invoked after the serialization finished. Read more
Source§fn container_shape(value: &T) -> ContainerShape
fn container_shape(value: &T) -> ContainerShape
Returns the shape of the value if it’s a map or sequence. Read more
impl StructuralPartialEq 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
Mutably borrows from an owned value. Read more