diff options
Diffstat (limited to 'openpgp/src/lib.rs')
-rw-r--r-- | openpgp/src/lib.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/openpgp/src/lib.rs b/openpgp/src/lib.rs index f7af0123..a8280d75 100644 --- a/openpgp/src/lib.rs +++ b/openpgp/src/lib.rs @@ -104,6 +104,16 @@ fn vec_drain_prefix(v: &mut Vec<u8>, prefix_len: usize) { } } +/// Like std::time::SystemTime::now, but works on WASM. +fn now() -> std::time::SystemTime { + #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] { + chrono::Utc::now().into() + } + #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] { + std::time::SystemTime::now() + } +} + // Like assert!, but checks a pattern. // // assert_match!(Some(_) = x); |