Skip to content

Commit

Permalink
RUST-1805 Only use js-sys with unknown os (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
abr-egn authored Nov 30, 2023
1 parent f2cd720 commit 412e456
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ serde_with-3 = { package = "serde_with", version = "3.1.0", optional = true }
time = { version = "0.3.9", features = ["formatting", "parsing", "macros", "large-dates"] }
bitvec = "1.0.1"

[target.'cfg(target_arch = "wasm32")'.dependencies]
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
js-sys = "0.3"
[dev-dependencies]
assert_matches = "1.2"
Expand Down
4 changes: 2 additions & 2 deletions src/oid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ impl ObjectId {
/// Generates a new timestamp representing the current seconds since epoch.
/// Represented in Big Endian.
fn gen_timestamp() -> [u8; 4] {
#[cfg(target_arch = "wasm32")]
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
let timestamp: u32 = (js_sys::Date::now() / 1000.0) as u32;
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
let timestamp: u32 = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.expect("system clock is before 1970")
Expand Down

0 comments on commit 412e456

Please sign in to comment.