| 1 |
// |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options |
| 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 resultHebrew = Temporal.ZonedDateTime.from({ |
| 33 |
era: "foobar", |
| 34 |
eraYear: 1, |
| 35 |
year: 5730, |
| 36 |
monthCode: "M04", |
| 37 |
day: 23, |
| 38 |
timeZone: "UTC", |
| 39 |
calendar: "hebrew", |
| 40 |
}); |
| 41 |
assert.sameValue(resultHebrew.epochNanoseconds, 0n, |
| 42 |
"era and eraYear are ignored for calendar not using eras (Hebrew)"); |
| 43 |
assert.sameValue(resultHebrew.calendarId, "hebrew"); |
| 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: "hebrew", |
| 52 |
}), "era and eraYear cannot replace year for calendar not using eras (Hebrew)"); |
| 53 |
|
| 54 |
reportCompare(0, 0); |