time-iso8601
Serialize and deserialize date-time in ISO-8601 format
Rust MIT
This is a serialization framework extension that formats OffsetDateTime structures from the time crate strictly into ISO-8601 format.
Usage
The crate provides a pre configured module designed to be passed directly to serde’s with attribute. This delegates the serialization and deserialization of the supported 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>,
}