summaryrefslogtreecommitdiff
path: root/crates/web-time-compat/src/wasm.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/web-time-compat/src/wasm.rs')
-rw-r--r--crates/web-time-compat/src/wasm.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/crates/web-time-compat/src/wasm.rs b/crates/web-time-compat/src/wasm.rs
new file mode 100644
index 000000000..37d2198ce
--- /dev/null
+++ b/crates/web-time-compat/src/wasm.rs
@@ -0,0 +1,20 @@
+//! Wasm-specific time functionality.
+
+// If we've forbidden `now` elsewhere in our project, we enable it here.
+#![allow(clippy::disallowed_methods)]
+
+pub use web_time::Instant;
+
+impl crate::SystemTimeExt for std::time::SystemTime {
+ fn get() -> std::time::SystemTime {
+ use web_time::web::SystemTimeExt as _;
+ let now = web_time::SystemTime::now();
+ now.to_std()
+ }
+}
+
+impl crate::InstantExt for Instant {
+ fn get() -> crate::Instant {
+ Instant::now()
+ }
+}