tor-browser

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

chinese-calendar-dates.js (1765B)


      1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
      2 // Copyright 2025 Google Inc, Igalia S.L. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-temporal.plainmonthday.from
      7 description: monthCode should work for Chinese calendar leap dates
      8 features: [Temporal]
      9 includes: [temporalHelpers.js]
     10 ---*/
     11 
     12 const calendar = "chinese";
     13 
     14 const monthDayCases = [
     15  {
     16    year: 2001,
     17    month: 5,
     18    monthCode: "M04L",
     19    day: 15,
     20    referenceYear: 1963
     21  },
     22  {
     23    year: 2000,
     24    month: 6,
     25    monthCode: "M06",
     26    day: 29,
     27    referenceYear: 1972
     28  },
     29 ];
     30 for (var {monthCode, month, day, year, referenceYear} of monthDayCases) {
     31  const md = Temporal.PlainMonthDay.from({
     32    year,
     33    month,
     34    day,
     35    calendar
     36  });
     37 
     38  TemporalHelpers.assertPlainMonthDay(md, monthCode, day, "md", referenceYear);
     39 
     40  const md2 = Temporal.PlainMonthDay.from({
     41    monthCode,
     42    day,
     43    calendar
     44  });
     45  TemporalHelpers.assertPlainMonthDay(md2, monthCode, day, "md2", referenceYear);
     46  assert.sameValue(md.equals(md2), true);
     47 
     48  assert.throws(RangeError, () => {
     49    Temporal.PlainMonthDay.from({
     50      monthCode: "M15",
     51      day: 1,
     52      calendar
     53    }, { overflow: "reject" });
     54  });
     55 
     56  assert.throws(RangeError, () => {
     57    Temporal.PlainMonthDay.from({
     58      monthCode: "M15",
     59      day: 1,
     60      calendar
     61    });
     62  });
     63 
     64  assert.throws(RangeError, () => {
     65    Temporal.PlainMonthDay.from({
     66      year,
     67      month: 15,
     68      day: 1,
     69      calendar
     70    }, { overflow: "reject" });
     71  });
     72 
     73  const constrained = Temporal.PlainMonthDay.from({
     74    year,
     75    month: 15,
     76    day: 1,
     77    calendar
     78  });
     79  assert.sameValue(constrained.monthCode, "M12");
     80 }
     81 
     82 reportCompare(0, 0);