| 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.plaindatetime.from |
| 7 |
description: era and eraYear are ignored (for calendars not using eras) |
| 8 |
includes: [temporalHelpers.js] |
| 9 |
features: [Temporal] |
| 10 |
---*/ |
| 11 |
|
| 12 |
const result = Temporal.PlainDateTime.from({ |
| 13 |
era: "foobar", |
| 14 |
eraYear: 1, |
| 15 |
year: 1970, |
| 16 |
monthCode: "M01", |
| 17 |
day: 1, |
| 18 |
calendar: "iso8601", |
| 19 |
}); |
| 20 |
TemporalHelpers.assertPlainDateTime(result, 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, |
| 21 |
"era and eraYear are ignored for calendar not using eras (iso8601)"); |
| 22 |
|
| 23 |
assert.throws(TypeError, () => Temporal.PlainDateTime.from({ |
| 24 |
era: "foobar", |
| 25 |
eraYear: 1, |
| 26 |
monthCode: "M01", |
| 27 |
day: 1, |
| 28 |
calendar: "iso8601", |
| 29 |
}), "era and eraYear cannot replace year for calendar not using eras (iso8601)"); |
| 30 |
|
| 31 |
const resultHebrew = Temporal.PlainDateTime.from({ |
| 32 |
era: "foobar", |
| 33 |
eraYear: 1, |
| 34 |
year: 5780, |
| 35 |
monthCode: "M01", |
| 36 |
day: 1, |
| 37 |
calendar: "hebrew", |
| 38 |
}); |
| 39 |
TemporalHelpers.assertPlainDateTime(resultHebrew, 5780, 1, "M01", 1, 0, 0, 0, 0, 0, 0, |
| 40 |
"era and eraYear are ignored for calendar not using eras (Hebrew)"); |
| 41 |
assert.sameValue(resultHebrew.calendarId, "hebrew"); |
| 42 |
|
| 43 |
assert.throws(TypeError, () => Temporal.PlainDateTime.from({ |
| 44 |
era: "foobar", |
| 45 |
eraYear: 1, |
| 46 |
monthCode: "M01", |
| 47 |
day: 1, |
| 48 |
calendar: "hebrew", |
| 49 |
}), "era and eraYear cannot replace year for calendar not using eras (Hebrew)"); |
| 50 |
|
| 51 |
reportCompare(0, 0); |