summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Intl/DateTimeFormat/formatRange-matches-format-output.js
blob: 67cebd184359f6493afbd3488ca627072f4da5a4 (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
// |reftest| skip-if(!this.hasOwnProperty("Intl"))

// formatRange() returns the same output as format() when the date-time difference between
// the start and end date is too small.

// Test case when skeleton can't be retrieved from resolved pattern (bug 1298794).
// - Best-fit pattern for the skeleton "MMMMMdd" is "M月dd日".
// - Best-fit pattern for the skeleton "Mdd" is "M/dd".
//
// So in both cases the skeleton characters in the pattern are "Mdd", which means we can't
// retrieve the original input skeleton by simply inspecting the resolved pattern.
//
// Also see: https://unicode-org.atlassian.net/browse/ICU-13518
{
    let dtf = new Intl.DateTimeFormat("zh", {month: "narrow", day: "2-digit", timeZone: "UTC"});
    assertEq(dtf.formatRange(0, 0), dtf.format(0));
}

// Test that date-/time-style leads to the same output.
// ICU bug: https://unicode-org.atlassian.net/browse/ICU-20710
{
    let dtf = new Intl.DateTimeFormat("en", {dateStyle: "full", timeStyle: "full"});
    assertEq(dtf.formatRange(0, 0), dtf.format(0));
}

// Test that the hourCycle option is correctly processed (test with h24).
// ICU bug: https://unicode-org.atlassian.net/browse/ICU-20707
{
    let dtf = new Intl.DateTimeFormat("en-u-hc-h24", {hour: "2-digit", timeZone:"UTC"});
    assertEq(dtf.formatRange(0, 0), dtf.format(0));
}
{
  let dtf = new Intl.DateTimeFormat("en", {hourCycle: "h24", hour: "2-digit", timeZone:"UTC"});
  assertEq(dtf.formatRange(0, 0), dtf.format(0));
}

// Test that the hourCycle option is correctly processed (test with h11).
// ICU bug: https://unicode-org.atlassian.net/browse/ICU-20707
{
    let dt = 60 * 60 * 1000; // one hour
    let dtf = new Intl.DateTimeFormat("en-u-hc-h11", {hour: "2-digit", timeZone:"UTC"});
    assertEq(dtf.formatRange(dt, dt), dtf.format(dt));
}
{
  let dt = 60 * 60 * 1000; // one hour
  let dtf = new Intl.DateTimeFormat("en", {hourCycle: "h11", hour: "2-digit", timeZone:"UTC"});
  assertEq(dtf.formatRange(dt, dt), dtf.format(dt));
}

// Test that non-default calendars work correctly.
// ICU bug: https://unicode-org.atlassian.net/browse/ICU-20706
{
    let dtf = new Intl.DateTimeFormat("en-001-u-ca-hebrew");
    assertEq(dtf.formatRange(0, 0), dtf.format(0));
}

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