Skip to content

Commit

Permalink
Eradicated dependency on obsolete time 0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenmartindale committed Oct 6, 2021
1 parent b79ce7e commit de92ac1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@ keywords = [ "time", "wasm" ]
edition = "2018"

[features]
now = [ "time" ]
wasm-bindgen = ["js-sys", "wasm-bindgen_rs", "web-sys"]
inaccurate = []
now = []

[dependencies]
cfg-if = "1.0"

[target.'cfg(not(any(feature = "stdweb", feature = "wasm-bindgen")))'.dependencies]
time = { version = "0.2", optional = true }

[target.wasm32-unknown-unknown.dependencies]
js-sys = { version = "0.3", optional = true }
stdweb = { version = "0.4", optional = true }
Expand Down
6 changes: 4 additions & 2 deletions src/native.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
pub type Instant = std::time::Instant;

/// The current time, in milliseconds.
/// The current time, expressed in milliseconds since the Unix Epoch.
#[cfg(feature = "now")]
pub fn now() -> f64 {
time::precise_time_s() * 1000.0
std::time::SystemTime::now().duration_since(std::time::SystemTime::UNIX_EPOCH)
.expect("System clock was before 1970.")
.as_secs_f64() * 1000.0
}

0 comments on commit de92ac1

Please sign in to comment.