tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

formatRange-matches-format-output.js (2297B)


      1 // |reftest| skip-if(!this.hasOwnProperty("Intl"))
      2 
      3 // formatRange() returns the same output as format() when the date-time difference between
      4 // the start and end date is too small.
      5 
      6 // Test case when skeleton can't be retrieved from resolved pattern (bug 1298794).
      7 // - Best-fit pattern for the skeleton "MMMMMdd" is "M月dd日".
      8 // - Best-fit pattern for the skeleton "Mdd" is "M/dd".
      9 //
     10 // So in both cases the skeleton characters in the pattern are "Mdd", which means we can't
     11 // retrieve the original input skeleton by simply inspecting the resolved pattern.
     12 //
     13 // Also see: https://unicode-org.atlassian.net/browse/ICU-13518
     14 {
     15    let dtf = new Intl.DateTimeFormat("zh", {month: "narrow", day: "2-digit", timeZone: "UTC"});
     16    assertEq(dtf.formatRange(0, 0), dtf.format(0));
     17 }
     18 
     19 // Test that date-/time-style leads to the same output.
     20 // ICU bug: https://unicode-org.atlassian.net/browse/ICU-20710
     21 {
     22    let dtf = new Intl.DateTimeFormat("en", {dateStyle: "full", timeStyle: "full"});
     23    assertEq(dtf.formatRange(0, 0), dtf.format(0));
     24 }
     25 
     26 // Test that the hourCycle option is correctly processed (test with h24).
     27 // ICU bug: https://unicode-org.atlassian.net/browse/ICU-20707
     28 {
     29    let dtf = new Intl.DateTimeFormat("en-u-hc-h24", {hour: "2-digit", timeZone:"UTC"});
     30    assertEq(dtf.formatRange(0, 0), dtf.format(0));
     31 }
     32 {
     33  let dtf = new Intl.DateTimeFormat("en", {hourCycle: "h24", hour: "2-digit", timeZone:"UTC"});
     34  assertEq(dtf.formatRange(0, 0), dtf.format(0));
     35 }
     36 
     37 // Test that the hourCycle option is correctly processed (test with h11).
     38 // ICU bug: https://unicode-org.atlassian.net/browse/ICU-20707
     39 {
     40    let dt = 60 * 60 * 1000; // one hour
     41    let dtf = new Intl.DateTimeFormat("en-u-hc-h11", {hour: "2-digit", timeZone:"UTC"});
     42    assertEq(dtf.formatRange(dt, dt), dtf.format(dt));
     43 }
     44 {
     45  let dt = 60 * 60 * 1000; // one hour
     46  let dtf = new Intl.DateTimeFormat("en", {hourCycle: "h11", hour: "2-digit", timeZone:"UTC"});
     47  assertEq(dtf.formatRange(dt, dt), dtf.format(dt));
     48 }
     49 
     50 // Test that non-default calendars work correctly.
     51 // ICU bug: https://unicode-org.atlassian.net/browse/ICU-20706
     52 {
     53    let dtf = new Intl.DateTimeFormat("en-001-u-ca-hebrew");
     54    assertEq(dtf.formatRange(0, 0), dtf.format(0));
     55 }
     56 
     57 if (typeof reportCompare === "function")
     58    reportCompare(0, 0);