1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 00:27:43 +00:00

LibJS: Update spec comments to use ToZeroPaddedDecimalString AO

This is an editorial change in the ECMA-262 and Temporal specs.

See:
- 843d8b8
- f9211d9

Note that we don't actually need to implement the AO as we already have
String::formatted() for this, and use unified format strings instead of
zero-padding in individual steps in many cases anyway.
This commit is contained in:
Linus Groh 2022-04-12 22:20:33 +01:00
parent 431a9938a8
commit 5397278bfc
10 changed files with 41 additions and 45 deletions

View file

@ -1661,7 +1661,7 @@ String temporal_duration_to_string(double years, double months, double weeks, do
// a. Let fraction be abs(milliseconds) × 10^6 + abs(microseconds) × 10^3 + abs(nanoseconds).
auto fraction = fabs(milliseconds) * 1'000'000 + fabs(microseconds) * 1'000 + fabs(nanoseconds);
// b. Let decimalPart be fraction formatted as a nine-digit decimal number, padded to the left with zeroes if necessary.
// b. Let decimalPart be ToZeroPaddedDecimalString(fraction, 9).
// NOTE: padding with zeros leads to weird results when applied to a double. Not sure if that's a bug in AK/Format.h or if I'm doing this wrong.
auto decimal_part = String::formatted("{:09}", (u64)fraction);