Serializes and deserializes OffsetDateTime
from the
time
crate in 4-digit year format with 2-digit time precision to
work with the majority of web frameworks.
use serde::{Serialize, Deserialize};
use time::OffsetDateTime;
#[derive(Debug, Serialize, Deserialize)]
struct User {
#[serde(with = "time-iso8601")]
datetime_field: OffsetDateTime,
#[serde(with = "time-iso8601::option")]
optional_field: Option<OffsetDateTime>,
}