summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Intl/DateTimeFormat/fractional-second-digits-append-item.js
blob: c85b310e56ceabe93c5669eff5ec4fb96901c266 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// |reftest| skip-if(!this.hasOwnProperty("Intl"))

if (typeof getBuildConfiguration === "undefined") {
  var getBuildConfiguration = SpecialPowers.Cu.getJSTestingFunctions().getBuildConfiguration;
}

var isNightly = !getBuildConfiguration().release_or_beta;

const {
  DayPeriod, Hour, Minute, Second, FractionalSecond, Literal
} = DateTimeFormatParts

const tests = [
  // https://unicode-org.atlassian.net/browse/CLDR-13184
  // https://unicode-org.atlassian.net/browse/CLDR-13623
  {
    locale: "en",
    date: new Date("2020-01-01T00:00:00.123"),
    options: {hour: "numeric", fractionalSecondDigits: 3},
    parts: [
      Hour("12"),
      Literal(" "),
      DayPeriod("AM"),
      Literal(" (Fractional Second: "),
      FractionalSecond("123"),
      Literal(")")
    ]
  },

  // https://unicode-org.atlassian.net/browse/ICU-20992
  {
    locale: "ckb-IR",
    date: new Date("2020-01-01T00:00:00.123"),
    options: {minute: "2-digit", fractionalSecondDigits: 3},
    parts: [
      Second("٠"),
      Literal("٫"),
      FractionalSecond("١٢٣"),
      Literal(" (Minute: "),
      Minute("٠"),
      Literal(")")
    ]
  },
];

if (isNightly) {
  // https://unicode-org.atlassian.net/browse/ICU-20992
  tests.push({
    locale: "ckb-IR",
    date: new Date("2020-01-01T00:00:00.123"),
    options: {dayPeriod: "short", fractionalSecondDigits: 3},
    parts: [
      FractionalSecond("١٢٣"),
      Literal(" (Dayperiod: "),
      DayPeriod("ب.ن"),
      Literal(")")
    ]
  });
}

for (let {locale, date, options, parts} of tests) {
  let dtf = new Intl.DateTimeFormat(locale, options);
  assertParts(dtf, date, parts);
}

if (typeof reportCompare === "function")
  reportCompare(0, 0, "ok");