diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-11-29 15:19:02 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-12-03 10:47:56 +0100 |
commit | 0266273998d5ebf74e07291225fc6b50d33bdbc9 (patch) | |
tree | d570842ddeffca8ee67a181d189049bdcc14b105 /openpgp/src/parse | |
parent | 80f4dab8a7c55102a9fd41d167add3d7c1193a31 (diff) |
openpgp: Use Timestamp in packet::Literal.
Diffstat (limited to 'openpgp/src/parse')
-rw-r--r-- | openpgp/src/parse/parse.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/openpgp/src/parse/parse.rs b/openpgp/src/parse/parse.rs index cda7bd46..b49f5139 100644 --- a/openpgp/src/parse/parse.rs +++ b/openpgp/src/parse/parse.rs @@ -6,7 +6,6 @@ use std::str; use std::mem; use std::fmt; use std::path::Path; -use std::time; use failure; use ::buffered_reader::*; @@ -35,6 +34,7 @@ use crate::types::{ HashAlgorithm, PublicKeyAlgorithm, SymmetricAlgorithm, + Timestamp, }; use crate::conversions::Time; use crate::crypto::{self, mpis::{PublicKey, MPI}}; @@ -1719,7 +1719,8 @@ impl Literal { literal.set_filename_from_bytes(&filename) .expect("length checked above"); } - literal.set_date(Some(time::SystemTime::from_pgp(date))); + literal.set_date( + Some(std::time::SystemTime::from(Timestamp::from(date))))?; let mut pp = php.ok(Packet::Literal(literal))?; // Enable hashing of the body. @@ -1745,7 +1746,7 @@ fn literal_parser_test () { if let &Packet::Literal(ref p) = p { assert_eq!(p.format(), DataFormat::Binary); assert_eq!(p.filename().unwrap()[..], b"foobar"[..]); - assert_eq!(p.date(), Some(time::SystemTime::from_pgp(1507458744))); + assert_eq!(p.date().unwrap(), Timestamp::from(1507458744).into()); assert_eq!(content, b"FOOBAR"); } else { panic!("Wrong packet!"); @@ -1762,7 +1763,7 @@ fn literal_parser_test () { assert_eq!(p.format(), DataFormat::Text); assert_eq!(p.filename().unwrap()[..], b"manifesto.txt"[..]); - assert_eq!(p.date(), Some(time::SystemTime::from_pgp(1508000649))); + assert_eq!(p.date().unwrap(), Timestamp::from(1508000649).into()); let expected = crate::tests::manifesto(); @@ -1878,8 +1879,8 @@ fn compressed_data_parser_test () { if let Packet::Literal(literal) = literal { assert_eq!(literal.filename(), None); assert_eq!(literal.format(), DataFormat::Binary); - assert_eq!(literal.date(), - Some(time::SystemTime::from_pgp(1509219866))); + assert_eq!(literal.date().unwrap(), + Timestamp::from(1509219866).into()); assert_eq!(content, expected.to_vec()); } else { panic!("Wrong packet!"); |