Skip to content

Conversation

sunfishcode
Copy link
Member

584 years ought to be enough for anyone.

584 years ought to be enough for anyone.
///
/// For completeness, this function traps if it's not possible to represent
/// the value of the clock in an `instant`. However, since `instant` can
/// represent over 584 years of time, this is not expected to occur in
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, but only if we also specify some restriction around the base time.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or rather, the approach to trap on overflow works, but the comment is misleading: you only get to represent 584 years if your base time is 0. Suggest including language like "implementations should ensure that base time is low enough to allow a sufficient range to monotonic_clock::now()" or something.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I've now added wording for this.

@sunfishcode sunfishcode merged commit d3a35df into WebAssembly:main Sep 8, 2025
1 check failed
@sunfishcode sunfishcode deleted the sunfishcode/trap-not-wrap branch September 8, 2025 21:51
@yoshuawuyts yoshuawuyts mentioned this pull request Sep 16, 2025
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

Successfully merging this pull request may close these issues.

4 participants