-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #685 from fortanix/raoul/rte-166-verify_tcb_info_d…
…ates [RTE-166] Verify tcb info dates
- Loading branch information
Showing
6 changed files
with
92 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use chrono::{DateTime, NaiveDateTime, Utc}; | ||
use serde::{Deserialize, Deserializer}; | ||
use serde::de; | ||
|
||
const ISO8601_FORMAT: &'static str = "%Y-%m-%dT%H:%M:%SZ"; | ||
|
||
pub fn serialize<S>(timestamp: &DateTime<Utc>, serializer: S) -> ::std::result::Result<S::Ok, S::Error> | ||
where | ||
S: ::serde::Serializer, | ||
{ | ||
let timestamp = timestamp.format(ISO8601_FORMAT).to_string(); | ||
serializer.serialize_str(×tamp) | ||
} | ||
|
||
pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result<DateTime<Utc>, D::Error> { | ||
let timestamp = String::deserialize(deserializer)?; | ||
let timestamp = NaiveDateTime::parse_from_str(×tamp, &ISO8601_FORMAT).map_err(de::Error::custom)?; | ||
Ok(timestamp.and_utc()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters