Module chrono::naive::serde::ts_nanoseconds
[−]
[src]
Used to serialize/deserialize from nanosecond-precision timestamps
Example:
use chrono::naive::serde::ts_nanoseconds; #[derive(Deserialize, Serialize)] struct S { #[serde(with = "ts_nanoseconds")] time: NaiveDateTime } let time = NaiveDate::from_ymd(2018, 5, 17).and_hms_nano(02, 04, 59, 918355733); let my_s = S { time: time.clone(), }; let as_string = serde_json::to_string(&my_s)?; assert_eq!(as_string, r#"{"time":1526522699918355733}"#); let my_s: S = serde_json::from_str(&as_string)?; assert_eq!(my_s.time, time);
Functions
deserialize |
Deserialize a |
serialize |
Serialize a UTC datetime into an integer number of nanoseconds since the epoch |