Attempts to deserialize an i64 and use as a Unix timestamp
(deserializer: D)
| 52 | |
| 53 | /// Attempts to deserialize an i64 and use as a Unix timestamp |
| 54 | pub fn deserialize<'de, D>(deserializer: D) -> Result<OffsetDateTime, D::Error> |
| 55 | where |
| 56 | D: Deserializer<'de>, |
| 57 | { |
| 58 | OffsetDateTime::from_unix_timestamp(i64::deserialize(deserializer)?) |
| 59 | .map_err(|_| serde::de::Error::custom("invalid Unix timestamp value")) |
| 60 | } |
| 61 | |
| 62 | #[cfg(test)] |
| 63 | mod tests { |
no outgoing calls
no test coverage detected