Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around https://github.com/sebcrozet/instant/issues/49 #2094

Merged
merged 2 commits into from
May 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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