Module nt_time::serde_with::rfc_3339

source ·
Available on crate features serde and serde-human-readable only.
Expand description

Use the well-known RFC 3339 format when serializing and deserializing a FileTime.

Use this module in combination with Serde’s with attribute.

§Examples

use nt_time::{
    serde::{Deserialize, Serialize},
    serde_with::rfc_3339,
    FileTime,
};

#[derive(Debug, Deserialize, PartialEq, Serialize)]
struct DateTime(#[serde(with = "rfc_3339")] FileTime);

let json = serde_json::to_string(&DateTime(FileTime::UNIX_EPOCH)).unwrap();
assert_eq!(json, r#""1970-01-01T00:00:00Z""#);

assert_eq!(
    serde_json::from_str::<DateTime>(&json).unwrap(),
    DateTime(FileTime::UNIX_EPOCH)
);

Modules§

Functions§