| 1 |
// Copyright 2018 Igalia, S.L. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
esid: sec-createdatetimeformat |
| 6 |
description: Checks the order of getting options for the DateTimeFormat constructor. |
| 7 |
includes: [compareArray.js] |
| 8 |
features: [Intl.DateTimeFormat-datetimestyle] |
| 9 |
---*/ |
| 10 |
|
| 11 |
// To be merged into constructor-options-order.js when the feature is removed. |
| 12 |
|
| 13 |
const expected = [ |
| 14 |
// CreateDateTimeFormat step 4. |
| 15 |
"localeMatcher", |
| 16 |
// CreateDateTimeFormat step 12. |
| 17 |
"hour12", |
| 18 |
// CreateDateTimeFormat step 13. |
| 19 |
"hourCycle", |
| 20 |
// CreateDateTimeFormat step 29. |
| 21 |
"timeZone", |
| 22 |
// CreateDateTimeFormat step 36. |
| 23 |
"weekday", |
| 24 |
"era", |
| 25 |
"year", |
| 26 |
"month", |
| 27 |
"day", |
| 28 |
"hour", |
| 29 |
"minute", |
| 30 |
"second", |
| 31 |
"timeZoneName", |
| 32 |
"formatMatcher", |
| 33 |
// CreateDateTimeFormat step 38. |
| 34 |
"dateStyle", |
| 35 |
// CreateDateTimeFormat step 40. |
| 36 |
"timeStyle", |
| 37 |
]; |
| 38 |
|
| 39 |
const actual = []; |
| 40 |
|
| 41 |
const options = { |
| 42 |
get dateStyle() { |
| 43 |
actual.push("dateStyle"); |
| 44 |
return undefined; |
| 45 |
}, |
| 46 |
|
| 47 |
get day() { |
| 48 |
actual.push("day"); |
| 49 |
return "numeric"; |
| 50 |
}, |
| 51 |
|
| 52 |
get era() { |
| 53 |
actual.push("era"); |
| 54 |
return "long"; |
| 55 |
}, |
| 56 |
|
| 57 |
get formatMatcher() { |
| 58 |
actual.push("formatMatcher"); |
| 59 |
return "best fit"; |
| 60 |
}, |
| 61 |
|
| 62 |
get hour() { |
| 63 |
actual.push("hour"); |
| 64 |
return "numeric"; |
| 65 |
}, |
| 66 |
|
| 67 |
get hour12() { |
| 68 |
actual.push("hour12"); |
| 69 |
return true; |
| 70 |
}, |
| 71 |
|
| 72 |
get hourCycle() { |
| 73 |
actual.push("hourCycle"); |
| 74 |
return "h24"; |
| 75 |
}, |
| 76 |
|
| 77 |
get localeMatcher() { |
| 78 |
actual.push("localeMatcher"); |
| 79 |
return "best fit"; |
| 80 |
}, |
| 81 |
|
| 82 |
get minute() { |
| 83 |
actual.push("minute"); |
| 84 |
return "numeric"; |
| 85 |
}, |
| 86 |
|
| 87 |
get month() { |
| 88 |
actual.push("month"); |
| 89 |
return "numeric"; |
| 90 |
}, |
| 91 |
|
| 92 |
get second() { |
| 93 |
actual.push("second"); |
| 94 |
return "numeric"; |
| 95 |
}, |
| 96 |
|
| 97 |
get timeStyle() { |
| 98 |
actual.push("timeStyle"); |
| 99 |
return undefined; |
| 100 |
}, |
| 101 |
|
| 102 |
get timeZone() { |
| 103 |
actual.push("timeZone"); |
| 104 |
return "UTC"; |
| 105 |
}, |
| 106 |
|
| 107 |
get timeZoneName() { |
| 108 |
actual.push("timeZoneName"); |
| 109 |
return "long"; |
| 110 |
}, |
| 111 |
|
| 112 |
get weekday() { |
| 113 |
actual.push("weekday"); |
| 114 |
return "long"; |
| 115 |
}, |
| 116 |
|
| 117 |
get year() { |
| 118 |
actual.push("year"); |
| 119 |
return "numeric"; |
| 120 |
}, |
| 121 |
}; |
| 122 |
|
| 123 |
new Intl.DateTimeFormat("en", options); |
| 124 |
|
| 125 |
assert.compareArray(actual, expected); |
| 126 |
|
| 127 |
reportCompare(0, 0); |