mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:37:37 +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:
parent
2fb332da7b
commit
765d016670
4 changed files with 7 additions and 7 deletions
|
@ -134,8 +134,8 @@ ThrowCompletionOr<Object*> DurationFormatConstructor::construct(FunctionObject&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 18. Set durationFormat.[[FractionalDigits]] to ? GetNumberOption(options, "fractionalDigits", 0, 9, undefined).
|
// 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, {}))));
|
duration_format->set_fractional_digits(Optional<u8>(TRY(get_number_option(vm, *options, vm.names.fractionalDigits, 0, 9, 0))));
|
||||||
|
|
||||||
// 19. Return durationFormat.
|
// 19. Return durationFormat.
|
||||||
return duration_format;
|
return duration_format;
|
||||||
|
|
|
@ -32,7 +32,7 @@ describe("correct behavior", () => {
|
||||||
"1y, 2m, 3w, 3d, 4h, 5m, 6s, 7ms, 8μs, and 9ns"
|
"1y, 2m, 3w, 3d, 4h, 5m, 6s, 7ms, 8μs, and 9ns"
|
||||||
);
|
);
|
||||||
expect(new Intl.DurationFormat("en", { style: "digital" }).format(duration)).toBe(
|
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(
|
expect(
|
||||||
new Intl.DurationFormat("en", {
|
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"
|
"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(
|
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(
|
expect(
|
||||||
new Intl.DurationFormat("de", {
|
new Intl.DurationFormat("de", {
|
||||||
|
|
|
@ -131,7 +131,7 @@ describe("correct behavior", () => {
|
||||||
{ type: "literal", value: ", " },
|
{ type: "literal", value: ", " },
|
||||||
{ type: "element", value: "3d" },
|
{ type: "element", value: "3d" },
|
||||||
{ type: "literal", value: ", and " },
|
{ type: "literal", value: ", and " },
|
||||||
{ type: "element", value: "4:05:06.007" },
|
{ type: "element", value: "4:05:06" },
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
|
@ -233,7 +233,7 @@ describe("correct behavior", () => {
|
||||||
{ type: "literal", value: ", " },
|
{ type: "literal", value: ", " },
|
||||||
{ type: "element", value: "3 T" },
|
{ type: "element", value: "3 T" },
|
||||||
{ type: "literal", value: " und " },
|
{ type: "literal", value: " und " },
|
||||||
{ type: "element", value: "4:05:06,007" },
|
{ type: "element", value: "4:05:06" },
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
|
|
|
@ -284,7 +284,7 @@ describe("correct behavior", () => {
|
||||||
|
|
||||||
test("fractionalDigits", () => {
|
test("fractionalDigits", () => {
|
||||||
const en1 = new Intl.DurationFormat("en");
|
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 => {
|
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].forEach(fractionalDigits => {
|
||||||
const en2 = new Intl.DurationFormat("en", { fractionalDigits: fractionalDigits });
|
const en2 = new Intl.DurationFormat("en", { fractionalDigits: fractionalDigits });
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue