mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 04:47:36 +00:00
LibJS: Set both {minimum, maximum}FractionDigits in Intl.DurationFormat
This is a normative change in the Intl.DurationFormat spec.
See: b293603e
This commit is contained in:
parent
fb8c4a724e
commit
1ebc5af2f0
3 changed files with 8 additions and 5 deletions
|
@ -378,7 +378,10 @@ ThrowCompletionOr<Vector<PatternPartition>> partition_duration_format_pattern(Gl
|
||||||
// iii. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", durationFormat.[[FractionalDigits]]).
|
// iii. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", durationFormat.[[FractionalDigits]]).
|
||||||
MUST(number_format_options->create_data_property_or_throw(vm.names.maximumFractionDigits, duration_format.has_fractional_digits() ? Value(duration_format.fractional_digits()) : js_undefined()));
|
MUST(number_format_options->create_data_property_or_throw(vm.names.maximumFractionDigits, duration_format.has_fractional_digits() ? Value(duration_format.fractional_digits()) : js_undefined()));
|
||||||
|
|
||||||
// iv. Set done to true.
|
// iv. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", durationFormat.[[FractionalDigits]]).
|
||||||
|
MUST(number_format_options->create_data_property_or_throw(vm.names.minimumFractionDigits, duration_format.has_fractional_digits() ? Value(duration_format.fractional_digits()) : js_undefined()));
|
||||||
|
|
||||||
|
// v. Set done to true.
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
// l. Else,
|
// l. Else,
|
||||||
|
|
|
@ -38,7 +38,7 @@ describe("correct behavior", () => {
|
||||||
new Intl.DurationFormat("en", {
|
new Intl.DurationFormat("en", {
|
||||||
style: "narrow",
|
style: "narrow",
|
||||||
nanoseconds: "numeric",
|
nanoseconds: "numeric",
|
||||||
fractionalDigits: 7,
|
fractionalDigits: 3,
|
||||||
}).format(duration)
|
}).format(duration)
|
||||||
).toBe("1y, 2m, 3w, 3d, 4h, 5m, 6s, 7ms, and 8.009μs");
|
).toBe("1y, 2m, 3w, 3d, 4h, 5m, 6s, 7ms, and 8.009μs");
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ describe("correct behavior", () => {
|
||||||
new Intl.DurationFormat("de", {
|
new Intl.DurationFormat("de", {
|
||||||
style: "narrow",
|
style: "narrow",
|
||||||
nanoseconds: "numeric",
|
nanoseconds: "numeric",
|
||||||
fractionalDigits: 7,
|
fractionalDigits: 3,
|
||||||
}).format(duration)
|
}).format(duration)
|
||||||
).toBe("1 J, 2 M, 3 W, 3 T, 4 Std., 5 Min., 6 Sek., 7 ms und 8,009 μs");
|
).toBe("1 J, 2 M, 3 W, 3 T, 4 Std., 5 Min., 6 Sek., 7 ms und 8,009 μs");
|
||||||
});
|
});
|
||||||
|
|
|
@ -138,7 +138,7 @@ describe("correct behavior", () => {
|
||||||
new Intl.DurationFormat("en", {
|
new Intl.DurationFormat("en", {
|
||||||
style: "narrow",
|
style: "narrow",
|
||||||
nanoseconds: "numeric",
|
nanoseconds: "numeric",
|
||||||
fractionalDigits: 7,
|
fractionalDigits: 3,
|
||||||
}).formatToParts(duration)
|
}).formatToParts(duration)
|
||||||
).toEqual([
|
).toEqual([
|
||||||
{ type: "element", value: "1y" },
|
{ type: "element", value: "1y" },
|
||||||
|
@ -240,7 +240,7 @@ describe("correct behavior", () => {
|
||||||
new Intl.DurationFormat("de", {
|
new Intl.DurationFormat("de", {
|
||||||
style: "narrow",
|
style: "narrow",
|
||||||
nanoseconds: "numeric",
|
nanoseconds: "numeric",
|
||||||
fractionalDigits: 7,
|
fractionalDigits: 3,
|
||||||
}).formatToParts(duration)
|
}).formatToParts(duration)
|
||||||
).toEqual([
|
).toEqual([
|
||||||
{ type: "element", value: "1 J" },
|
{ type: "element", value: "1 J" },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue