Skip to content

Commit

Permalink
Merge pull request #690 from kmusick/fix-cloudflare-workers-timestamp
Browse files Browse the repository at this point in the history
Fixing issue with Cloudflare Workers and wasm32-unknown-unknown when using now()
  • Loading branch information
KodrAus authored Jun 26, 2023
2 parents bf7fe91 + b5f16b9 commit 934f10c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ fn now() -> (u64, u32) {

#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = Date)]
fn now() -> f64;
#[wasm_bindgen(js_namespace = Date, catch)]
fn now() -> Result<f64, JsValue>;
}

let now = now();
let now = now().unwrap_throw();

let secs = (now / 1_000.0) as u64;
let nanos = ((now % 1_000.0) * 1_000_000.0) as u32;
Expand Down

0 comments on commit 934f10c

Please sign in to comment.