Skip to content

Commit

Permalink
Work around sebcrozet/instant#49 (#2094)
Browse files Browse the repository at this point in the history
* Work around sebcrozet/instant#49

* Link to new issue
  • Loading branch information
jleibs committed May 12, 2023
1 parent e4bdad8 commit 0a19555
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/re_log_types/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,20 @@ pub struct Time(i64);
impl Time {
#[inline]
pub fn now() -> Self {
// TODO(https://github.com/rerun-io/rerun/issues/2105): Even though `instant` should work on wasm,
// `elapsed` is broken. See: https://github.com/sebcrozet/instant/issues/49
//
// For now, we implement what elapsed is supposed to do ourselves.
/*
let nanos_since_epoch = instant::SystemTime::UNIX_EPOCH
.elapsed()
.expect("Expected system clock to be set to after 1970")
.as_nanos() as _;
*/
let nanos_since_epoch = instant::SystemTime::now()
.duration_since(instant::SystemTime::UNIX_EPOCH)
.expect("Expected system clock to be set to after 1970")
.as_nanos() as _;
Self(nanos_since_epoch)
}

Expand Down

0 comments on commit 0a19555

Please sign in to comment.