1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:07:35 +00:00

LibJS: Default to 0 for DurationFormat's fractionalDigits option

This is a normative change in the Intl.DurationFormat proposal. See:
ac7e184
This commit is contained in:
Timothy Flynn 2022-08-30 10:18:13 -04:00 committed by Tim Flynn
parent 2fb332da7b
commit 765d016670
4 changed files with 7 additions and 7 deletions

View file

@ -134,8 +134,8 @@ ThrowCompletionOr<Object*> DurationFormatConstructor::construct(FunctionObject&
}
}
// 18. Set durationFormat.[[FractionalDigits]] to ? GetNumberOption(options, "fractionalDigits", 0, 9, undefined).
duration_format->set_fractional_digits(Optional<u8>(TRY(get_number_option(vm, *options, vm.names.fractionalDigits, 0, 9, {}))));
// 18. Set durationFormat.[[FractionalDigits]] to ? GetNumberOption(options, "fractionalDigits", 0, 9, 0).
duration_format->set_fractional_digits(Optional<u8>(TRY(get_number_option(vm, *options, vm.names.fractionalDigits, 0, 9, 0))));
// 19. Return durationFormat.
return duration_format;

View file

@ -32,7 +32,7 @@ describe("correct behavior", () => {
"1y, 2m, 3w, 3d, 4h, 5m, 6s, 7ms, 8μs, and 9ns"
);
expect(new Intl.DurationFormat("en", { style: "digital" }).format(duration)).toBe(
"1y, 2m, 3w, 3d, and 4:05:06.007"
"1y, 2m, 3w, 3d, and 4:05:06"
);
expect(
new Intl.DurationFormat("en", {
@ -52,7 +52,7 @@ describe("correct behavior", () => {
"1 J, 2 M, 3 W, 3 T, 4 Std., 5 Min., 6 Sek., 7 ms, 8 μs und 9 ns"
);
expect(new Intl.DurationFormat("de", { style: "digital" }).format(duration)).toBe(
"1 J, 2 M, 3 W, 3 T und 4:05:06,007"
"1 J, 2 M, 3 W, 3 T und 4:05:06"
);
expect(
new Intl.DurationFormat("de", {

View file

@ -131,7 +131,7 @@ describe("correct behavior", () => {
{ type: "literal", value: ", " },
{ type: "element", value: "3d" },
{ type: "literal", value: ", and " },
{ type: "element", value: "4:05:06.007" },
{ type: "element", value: "4:05:06" },
]
);
expect(
@ -233,7 +233,7 @@ describe("correct behavior", () => {
{ type: "literal", value: ", " },
{ type: "element", value: "3 T" },
{ type: "literal", value: " und " },
{ type: "element", value: "4:05:06,007" },
{ type: "element", value: "4:05:06" },
]
);
expect(

View file

@ -284,7 +284,7 @@ describe("correct behavior", () => {
test("fractionalDigits", () => {
const en1 = new Intl.DurationFormat("en");
expect(en1.resolvedOptions().fractionalDigits).toBeUndefined();
expect(en1.resolvedOptions().fractionalDigits).toBe(0);
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].forEach(fractionalDigits => {
const en2 = new Intl.DurationFormat("en", { fractionalDigits: fractionalDigits });