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

Instant::elapsed panics if time goes backwards, when inaccurate feature is enabled #53

Open
richvdh opened this issue Dec 13, 2023 · 0 comments

Comments

@richvdh
Copy link

richvdh commented Dec 13, 2023

STR:

  • Create an Instant: let now = Instant::now();
  • Later: check how long has passed now.elapsed();

If system time goes backwards in the intervening period, elapsed will panic:

panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/instant-0.1.12/src/wasm.rs:24:9:
`earlier` cannot be later than `self`.

This seems to be largely because Instant is based on local system time rather than a proper monotonic clock, violating the specification of std::time::Instant. I think if we're going to do that, we need to let Instant::duration_since saturate rather than panic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant