diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-11-20 19:02:34 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-11-21 16:25:30 +0100 |
commit | b251f9e8857fba284f515061ac62013519997e30 (patch) | |
tree | 8cb3501b8cb32e43496e56dd76446ba7559c7eed /openpgp-ffi/src/packet | |
parent | 13c437470cc7377d7b761b5bb9b8d4efb0ba385e (diff) |
openpgp: Replace time crate with std::time.
- In sq and sqv, use chrono to interface with the user.
- Fixes #341.
Diffstat (limited to 'openpgp-ffi/src/packet')
-rw-r--r-- | openpgp-ffi/src/packet/key.rs | 3 | ||||
-rw-r--r-- | openpgp-ffi/src/packet/mod.rs | 1 | ||||
-rw-r--r-- | openpgp-ffi/src/packet/signature.rs | 12 |
3 files changed, 8 insertions, 8 deletions
diff --git a/openpgp-ffi/src/packet/key.rs b/openpgp-ffi/src/packet/key.rs index 0229a301..e0eead22 100644 --- a/openpgp-ffi/src/packet/key.rs +++ b/openpgp-ffi/src/packet/key.rs @@ -47,7 +47,8 @@ fn pgp_key_creation_time(key: *const Key) -> time_t { let key = key.ref_raw(); let ct = key.creation_time(); - ct.to_timespec().sec as time_t + ct.duration_since(std::time::UNIX_EPOCH).map(|d| d.as_secs()) + .unwrap_or(0) as time_t } /// Returns the key's public key algorithm. diff --git a/openpgp-ffi/src/packet/mod.rs b/openpgp-ffi/src/packet/mod.rs index 7bab6195..deef792a 100644 --- a/openpgp-ffi/src/packet/mod.rs +++ b/openpgp-ffi/src/packet/mod.rs @@ -7,7 +7,6 @@ use libc::c_char; extern crate sequoia_openpgp as openpgp; -extern crate time; use self::openpgp::{ packet::Tag, diff --git a/openpgp-ffi/src/packet/signature.rs b/openpgp-ffi/src/packet/signature.rs index 2b1b301e..14df1ce3 100644 --- a/openpgp-ffi/src/packet/signature.rs +++ b/openpgp-ffi/src/packet/signature.rs @@ -172,7 +172,7 @@ fn pgp_signature_alive(sig: *const Signature, time: time_t) let time = if time == 0 { None } else { - Some(time::at(time::Timespec::new(time as i64, 0))) + Some(std::time::UNIX_EPOCH + std::time::Duration::new(time as u64, 0)) }; sig.ref_raw().signature_alive(time, None) } @@ -233,9 +233,9 @@ fn pgp_signature_alive_with_tolerance(sig: *const Signature, let time = if time == 0 { None } else { - Some(time::at(time::Timespec::new(time as i64, 0))) + Some(std::time::UNIX_EPOCH + std::time::Duration::new(time as u64, 0)) }; - let tolerance = time::Duration::seconds(tolerance as i64); + let tolerance = std::time::Duration::new(tolerance as u64, 0); sig.ref_raw().signature_alive(time, Some(tolerance)) } @@ -247,7 +247,7 @@ fn pgp_signature_expired(sig: *const Signature, when: time_t) -> bool { let t = if when == 0 { None } else { - Some(time::at(time::Timespec::new(when as i64, 0))) + Some(std::time::UNIX_EPOCH + std::time::Duration::new(when as u64, 0)) }; sig.ref_raw().signature_expired(t) } @@ -265,7 +265,7 @@ fn pgp_signature_key_alive(sig: *const Signature, key: *const Key, let t = if when == 0 { None } else { - Some(time::at(time::Timespec::new(when as i64, 0))) + Some(std::time::UNIX_EPOCH + std::time::Duration::new(when as u64, 0)) }; sig.ref_raw().key_alive(key.ref_raw(), t) } @@ -279,7 +279,7 @@ fn pgp_signature_key_expired(sig: *const Signature, key: *const Key, let t = if when == 0 { None } else { - Some(time::at(time::Timespec::new(when as i64, 0))) + Some(std::time::UNIX_EPOCH + std::time::Duration::new(when as u64, 0)) }; sig.ref_raw().key_expired(key.ref_raw(), t) } |