Module nt_time::serde::rfc_2822

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

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

Use this module in combination with Serde’s #[with] attribute.

Examples

use nt_time::{serde::rfc_2822, FileTime};
use serde::{Deserialize, Serialize};

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

let json = serde_json::to_string(&DateTime(FileTime::UNIX_EPOCH)).unwrap();
assert_eq!(json, r#""Thu, 01 Jan 1970 00:00:00 +0000""#);

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

Modules

Functions