Module nt_time::serde_with::iso_8601
source · Available on crate features
serde
and serde-human-readable
only.Expand description
Use the well-known ISO 8601 format when serializing and deserializing a
FileTime
.
Use this module in combination with Serde’s with
attribute.
If the large-dates
feature is not enabled, the maximum date and time is
“9999-12-31 23:59:59.999999999 UTC”.
§Examples
use nt_time::{
serde::{Deserialize, Serialize},
serde_with::iso_8601,
FileTime,
};
#[derive(Debug, Deserialize, PartialEq, Serialize)]
struct DateTime(#[serde(with = "iso_8601")] FileTime);
let json = serde_json::to_string(&DateTime(FileTime::UNIX_EPOCH)).unwrap();
assert_eq!(json, r#""+001970-01-01T00:00:00.000000000Z""#);
assert_eq!(
serde_json::from_str::<DateTime>(&json).unwrap(),
DateTime(FileTime::UNIX_EPOCH)
);
Modules§
- Use the well-known ISO 8601 format when serializing and deserializing an
Option<FileTime>
.