tor-browser

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

calendar-not-supporting-eras.js (1533B)


      1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
      2 // Copyright (C) 2024 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.zoneddatetime.from
      7 description: era and eraYear are ignored (for calendars not using eras)
      8 features: [BigInt, Temporal]
      9 ---*/
     10 
     11 const result = Temporal.ZonedDateTime.from({
     12  era: "foobar",
     13  eraYear: 1,
     14  year: 1970,
     15  monthCode: "M01",
     16  day: 1,
     17  timeZone: "UTC",
     18  calendar: "iso8601",
     19 });
     20 assert.sameValue(result.epochNanoseconds, 0n,
     21  "era and eraYear are ignored for calendar not using eras (iso8601)");
     22 
     23 assert.throws(TypeError, () => Temporal.ZonedDateTime.from({
     24  era: "foobar",
     25  eraYear: 1,
     26  monthCode: "M01",
     27  day: 1,
     28  timeZone: "UTC",
     29  calendar: "iso8601",
     30 }), "era and eraYear cannot replace year for calendar not using eras (iso8601)");
     31 
     32 const resultChinese = Temporal.ZonedDateTime.from({
     33  era: "foobar",
     34  eraYear: 1,
     35  year: 1969,
     36  monthCode: "M11",
     37  day: 24,
     38  timeZone: "UTC",
     39  calendar: "chinese",
     40 });
     41 assert.sameValue(resultChinese.epochNanoseconds, 0n,
     42  "era and eraYear are ignored for calendar not using eras (Chinese)");
     43 assert.sameValue(resultChinese.calendarId, "chinese");
     44 
     45 assert.throws(TypeError, () => Temporal.ZonedDateTime.from({
     46  era: "foobar",
     47  eraYear: 1,
     48  monthCode: "M01",
     49  day: 1,
     50  timeZone: "UTC",
     51  calendar: "chinese",
     52 }), "era and eraYear cannot replace year for calendar not using eras (Chinese)");
     53 
     54 reportCompare(0, 0);