-
Notifications
You must be signed in to change notification settings - Fork 153
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
Normative: Use floor instead of truncate in epoch time getters #2424
Conversation
In Temporal.{Instant,ZonedDateTime}.epoch{S,Millis,Micros}econds, the rounding should use floor instead of truncate semantics, in order to always truncate towards the beginning of time, as .toString() and .round() do. Closes: #2423
Draft until presented at TC39. The reference code already worked as described in this change, and the behaviour is already covered by test262. |
Codecov Report
@@ Coverage Diff @@
## main #2424 +/- ##
=======================================
Coverage 94.66% 94.66%
=======================================
Files 20 20
Lines 11074 11074
Branches 1970 1970
=======================================
Hits 10483 10483
Misses 544 544
Partials 47 47 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
This change achieved consensus at the TC39 plenary meeting today. |
Update tests to match <tc39/proposal-temporal#2424>.
See #2423 for the issue and #2424 for the spec text change, which was already adopted some time ago. I thought the reference code already worked like this, but it does not. Anba pointed this out in tc39/test262#3802 and provided correct test262 tests for the feature. Note that the big-integer library doesn't have a floor division function. We roll our own. If the divisor or dividend is negative (but not both) and there is a remainder, then we subtract 1 from the result (round towards negative infinity instead of 0).
Update tests to match <tc39/proposal-temporal#2424>.
Update tests to match <tc39/proposal-temporal#2424>.
See #2423 for the issue and #2424 for the spec text change, which was already adopted some time ago. I thought the reference code already worked like this, but it does not. Anba pointed this out in tc39/test262#3802 and provided correct test262 tests for the feature. Note that the big-integer library doesn't have a floor division function. We roll our own. If the divisor or dividend is negative (but not both) and there is a remainder, then we subtract 1 from the result (round towards negative infinity instead of 0).
See #2423 for the issue and #2424 for the spec text change, which was already adopted some time ago. I thought the reference code already worked like this, but it does not. Anba pointed this out in tc39/test262#3802 and provided correct test262 tests for the feature. Note that the big-integer library doesn't have a floor division function. We roll our own. If the divisor or dividend is negative (but not both) and there is a remainder, then we subtract 1 from the result (round towards negative infinity instead of 0).
See #2423 for the issue and #2424 for the spec text change, which was already adopted some time ago. I thought the reference code already worked like this, but it does not. Anba pointed this out in tc39/test262#3802 and provided correct test262 tests for the feature. Note that the big-integer library doesn't have a floor division function. We roll our own. If the divisor or dividend is negative (but not both) and there is a remainder, then we subtract 1 from the result (round towards negative infinity instead of 0). UPSTREAM_COMMIT=6e0ad2030170540084a4a400005cc2bc8c791bdb
In Temporal.{Instant,ZonedDateTime}.epoch{S,Millis,Micros}econds, the rounding should use floor instead of truncate semantics, in order to always truncate towards the beginning of time, as .toString() and .round() do.
Closes: #2423