time-iso8601
Serialize and deserialize date-time in ISO-8601 format
Rust MIT
This serialization framework extension formats OffsetDateTime structures from the time crate into ISO-8601 format.
Usage
The crate provides a module designed to be passed to serde’s with attribute. This delegates the serialization and deserialization of OffsetDateTime fields to the formatter.
The framework handles both standard fields and optional fields:
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
#[derive(Debug, Serialize, Deserialize)]
struct User {
// standard datetime fields
#[serde(with = "time_iso8601")]
created_at: OffsetDateTime,
// optional fields
#[serde(with = "time_iso8601::option")]
updated_at: Option<OffsetDateTime>,
}