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
Duration format with precision: "second" #1859
Comments
Similar issue with test/test262/data/test/built-ins/Temporal/Duration/prototype/toString/blank-duration-precision.js Following the current spec text will output "PT0.000000000S" not "PT0S" for the same reason |
Also test/built-ins/Temporal/Duration/prototype/toString/roundingmode-undefined.js duration.toString({ smallestUnit: "second", roundingMode: undefined }) |
This was closed by #1860. |
I think I find a bug when I try to fix my v8 implementaiton of broken test
built-ins/Temporal/Duration/prototype/toString/smallestunit-valid-units.js
what should be the result of
const duration = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321);
duration.toString({ smallestUnit: "second" })
The test said it should be "P1Y2M3W4DT5H6M7S"
but my implementation output "P1Y2M3W4DT5H6M7.000000000S"
Here is why, in
after
precision is { [[Precision]]: 0, [[Unit]]: "second", [[Increment]]: 1 }.
and then
now the values of the last 5 args are
Now, in https://tc39.es/proposal-temporal/#sec-temporal-temporaldurationtostring
since seconds is 7, it will get into the block:
after
so fraction is 0 and decimalPart is "000000000"
Since precision is 0, it will not get into either c-i nor d-i and therefore decimalPart is still "000000000"
now secondsPart = "7"
since decimalPart is "000000000" it will get into f-i block and secondsPart will now = "7.000000000"
I think the problem is we need to change d to
The text was updated successfully, but these errors were encountered: