| 1 |
// Copyright 2019 Googe Inc. All rights reserved. |
| 2 |
// Copyright 2020 Apple Inc. All rights reserved. |
| 3 |
// This code is governed by the BSD license found in the LICENSE file. |
| 4 |
|
| 5 |
/*--- |
| 6 |
esid: sec-createdatetimeformat |
| 7 |
description: Checks the order of getting options of 'fractionalSecondDigits' for the DateTimeFormat constructor. |
| 8 |
info: | |
| 9 |
CreateDateTimeFormat ( newTarget, locales, options, required, defaults ) |
| 10 |
... |
| 11 |
4. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit"). |
| 12 |
... |
| 13 |
36. For each row of Table 7, except the header row, in table order, do |
| 14 |
a. Let prop be the name given in the Property column of the row. |
| 15 |
b. If prop is "fractionalSecondDigits", then |
| 16 |
i. Let value be ? GetNumberOption(options, "fractionalSecondDigits", 1, 3, undefined). |
| 17 |
c. Else, |
| 18 |
i. Let values be a List whose elements are the strings given in the Values column of the row. |
| 19 |
ii. Let value be ? GetOption(options, prop, string, values, undefined). |
| 20 |
d. Set formatOptions.[[<prop>]] to value. |
| 21 |
37. Let matcher be ? GetOption(options, "formatMatcher", "string", « "basic", "best fit" », "best fit"). |
| 22 |
... |
| 23 |
includes: [compareArray.js] |
| 24 |
features: [Intl.DateTimeFormat-fractionalSecondDigits] |
| 25 |
---*/ |
| 26 |
|
| 27 |
// Just need to ensure fractionalSecondDigits are get |
| 28 |
// between "second" and "timeZoneName". |
| 29 |
const expected = [ |
| 30 |
// CreateDateTimeFormat step 4. |
| 31 |
"localeMatcher", |
| 32 |
// CreateDateTimeFormat step 36. |
| 33 |
"second", |
| 34 |
"fractionalSecondDigits", |
| 35 |
"timeZoneName", |
| 36 |
// CreateDateTimeFormat step 37. |
| 37 |
"formatMatcher", |
| 38 |
]; |
| 39 |
|
| 40 |
const actual = []; |
| 41 |
|
| 42 |
const options = { |
| 43 |
get second() { |
| 44 |
actual.push("second"); |
| 45 |
return "numeric"; |
| 46 |
}, |
| 47 |
get fractionalSecondDigits() { |
| 48 |
actual.push("fractionalSecondDigits"); |
| 49 |
return undefined; |
| 50 |
}, |
| 51 |
get localeMatcher() { |
| 52 |
actual.push("localeMatcher"); |
| 53 |
return undefined; |
| 54 |
}, |
| 55 |
get timeZoneName() { |
| 56 |
actual.push("timeZoneName"); |
| 57 |
return undefined; |
| 58 |
}, |
| 59 |
get formatMatcher() { |
| 60 |
actual.push("formatMatcher"); |
| 61 |
return undefined; |
| 62 |
}, |
| 63 |
}; |
| 64 |
|
| 65 |
new Intl.DateTimeFormat("en", options); |
| 66 |
assert.compareArray(actual, expected); |
| 67 |
|
| 68 |
reportCompare(0, 0); |