openpgp: New function to normalize SystemTime.

parent 628182f3
......@@ -22,6 +22,7 @@ mod server_preferences;
pub use self::server_preferences::KeyServerPreferences;
mod timestamp;
pub use timestamp::{Timestamp, Duration};
pub(crate) use timestamp::normalize_systemtime;
/// Removes padding bytes from bitfields.
///
......
......@@ -455,6 +455,13 @@ impl Arbitrary for Duration {
}
}
/// Normalizes the given SystemTime to the resolution OpenPGP
/// supports.
pub(crate) fn normalize_systemtime(t: SystemTime) -> SystemTime {
UNIX_EPOCH + SystemDuration::new(
t.duration_since(UNIX_EPOCH).unwrap().as_secs(), 0)
}
#[cfg(test)]
mod tests {
use super::*;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment