2019-06-12 17:55:53 +02:00
|
|
|
|
// Copyright 2019 Googe Inc. All rights reserved.
|
2020-08-26 21:38:29 +02:00
|
|
|
|
// Copyright 2020 Apple Inc. All rights reserved.
|
2019-06-12 17:55:53 +02:00
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
/*---
|
2023-01-12 14:22:34 +01:00
|
|
|
|
esid: sec-createdatetimeformat
|
2019-06-12 17:55:53 +02:00
|
|
|
|
description: Checks the order of getting options of 'fractionalSecondDigits' for the DateTimeFormat constructor.
|
|
|
|
|
info: |
|
2023-01-12 14:22:34 +01:00
|
|
|
|
CreateDateTimeFormat ( newTarget, locales, options, required, defaults )
|
|
|
|
|
...
|
2019-06-12 19:21:28 +02:00
|
|
|
|
4. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
|
2023-01-12 14:22:34 +01:00
|
|
|
|
...
|
|
|
|
|
36. For each row of Table 7, except the header row, in table order, do
|
|
|
|
|
a. Let prop be the name given in the Property column of the row.
|
|
|
|
|
b. If prop is "fractionalSecondDigits", then
|
|
|
|
|
i. Let value be ? GetNumberOption(options, "fractionalSecondDigits", 1, 3, undefined).
|
|
|
|
|
c. Else,
|
|
|
|
|
i. Let values be a List whose elements are the strings given in the Values column of the row.
|
|
|
|
|
ii. Let value be ? GetOption(options, prop, string, values, undefined).
|
|
|
|
|
d. Set formatOptions.[[<prop>]] to value.
|
|
|
|
|
37. Let matcher be ? GetOption(options, "formatMatcher", "string", « "basic", "best fit" », "best fit").
|
|
|
|
|
...
|
2019-06-12 17:55:53 +02:00
|
|
|
|
includes: [compareArray.js]
|
|
|
|
|
features: [Intl.DateTimeFormat-fractionalSecondDigits]
|
|
|
|
|
---*/
|
|
|
|
|
|
|
|
|
|
// Just need to ensure fractionalSecondDigits are get
|
2023-01-12 14:22:34 +01:00
|
|
|
|
// between "second" and "timeZoneName".
|
2019-06-12 17:55:53 +02:00
|
|
|
|
const expected = [
|
2023-01-12 14:22:34 +01:00
|
|
|
|
// CreateDateTimeFormat step 4.
|
2019-06-12 17:55:53 +02:00
|
|
|
|
"localeMatcher",
|
2023-01-12 14:22:34 +01:00
|
|
|
|
// CreateDateTimeFormat step 36.
|
2019-06-12 17:55:53 +02:00
|
|
|
|
"second",
|
|
|
|
|
"fractionalSecondDigits",
|
2020-08-26 21:38:29 +02:00
|
|
|
|
"timeZoneName",
|
2023-01-12 14:22:34 +01:00
|
|
|
|
// CreateDateTimeFormat step 37.
|
2019-06-12 17:55:53 +02:00
|
|
|
|
"formatMatcher",
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const actual = [];
|
|
|
|
|
|
|
|
|
|
const options = {
|
|
|
|
|
get second() {
|
|
|
|
|
actual.push("second");
|
|
|
|
|
return "numeric";
|
|
|
|
|
},
|
|
|
|
|
get fractionalSecondDigits() {
|
|
|
|
|
actual.push("fractionalSecondDigits");
|
|
|
|
|
return undefined;
|
|
|
|
|
},
|
|
|
|
|
get localeMatcher() {
|
|
|
|
|
actual.push("localeMatcher");
|
|
|
|
|
return undefined;
|
|
|
|
|
},
|
|
|
|
|
get timeZoneName() {
|
|
|
|
|
actual.push("timeZoneName");
|
|
|
|
|
return undefined;
|
|
|
|
|
},
|
|
|
|
|
get formatMatcher() {
|
|
|
|
|
actual.push("formatMatcher");
|
|
|
|
|
return undefined;
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
new Intl.DateTimeFormat("en", options);
|
|
|
|
|
assert.compareArray(actual, expected);
|