tor-browser

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

fractional-second-digits.js (1306B)


      1 // |reftest| skip-if(!this.hasOwnProperty("Intl"))
      2 
      3 const {
      4    Second, FractionalSecond, Literal
      5 } = DateTimeFormatParts
      6 
      7 const tests = [
      8  {
      9      date: new Date("2019-01-01T00:00:00.123"),
     10      digits: {
     11          1: [Second("0"), Literal("."), FractionalSecond("1")],
     12          2: [Second("0"), Literal("."), FractionalSecond("12")],
     13          3: [Second("0"), Literal("."), FractionalSecond("123")],
     14      }
     15  },
     16  {
     17      date: new Date("2019-01-01T00:00:00.023"),
     18      digits: {
     19          1: [Second("0"), Literal("."), FractionalSecond("0")],
     20          2: [Second("0"), Literal("."), FractionalSecond("02")],
     21          3: [Second("0"), Literal("."), FractionalSecond("023")],
     22      }
     23  },
     24  {
     25      date: new Date("2019-01-01T00:00:00.003"),
     26      digits: {
     27          1: [Second("0"), Literal("."), FractionalSecond("0")],
     28          2: [Second("0"), Literal("."), FractionalSecond("00")],
     29          3: [Second("0"), Literal("."), FractionalSecond("003")],
     30      }
     31  },
     32 ];
     33 
     34 for (let {date, digits} of tests) {
     35    for (let [fractionalSecondDigits, parts] of Object.entries(digits)) {
     36        let dtf = new Intl.DateTimeFormat("en", {second: "numeric", fractionalSecondDigits});
     37 
     38        assertParts(dtf, date, parts);
     39    }
     40 }
     41 
     42 if (typeof reportCompare === "function")
     43  reportCompare(0, 0, "ok");