Source code

Revision control

Copy as Markdown

Other Tools

// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.from
description: Non-positive era years in calendars with a single era
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendarEras = {
buddhist: "be",
coptic: "am",
ethioaa: "aa",
hebrew: "am",
indian: "shaka",
persian: "ap",
};
const options = { overflow: "reject" };
for (const [calendar, era] of Object.entries(calendarEras)) {
for (const eraYear of [-1, 0, 1]) {
const date = Temporal.ZonedDateTime.from({ era, eraYear, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
TemporalHelpers.assertPlainDateTime(
date.toPlainDateTime(),
eraYear, 1, "M01", 1, 12, 34, 0, 0, 0, 0, `era year ${eraYear} is not remapped`,
era, eraYear);
}
}
reportCompare(0, 0);