#iso-8601

time-iso8601

Serialize and deserialize date-time in ISO-8601 format

1 unstable release

0.1.0 Apr 15, 2024

#18 in #iso-8601

MIT license

3KB

time-iso8601

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.

Examples

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>,
}

Dependencies

~0.8–1MB
~21K SLoC