Intl Era Monthcode: DateTimeFormat.resolvedOptions().calendar

Tests the Intl.DateTimeFormat.prototype.resolvedOptions().calendar value
for each supported calendar.

Co-Authored-By: Philip Chimento <pchimento@igalia.com>
This commit is contained in:
Jesse Alama 2025-11-11 09:57:48 -08:00 committed by Philip Chimento
parent 0186d50ba0
commit a4c57b679b

View File

@ -0,0 +1,45 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-intl.datetimeformat.prototype.resolvedoptions
description: Verifies that the calendar option is respected.
locale: [en]
features: [Intl.Era-monthcode]
---*/
const tests = [
"buddhist",
"chinese",
"coptic",
"dangi",
"ethioaa",
"ethiopic",
"gregory",
"hebrew",
"indian",
"islamic-civil",
"islamic-tbla",
"islamic-umalqura",
"iso8601",
"japanese",
"persian",
"roc",
];
for (const calendar of tests) {
const formatter = new Intl.DateTimeFormat("en", { calendar });
const options = formatter.resolvedOptions();
assert.sameValue(options.calendar, calendar, "Resolved calendar");
}
const aliases = [
["ethiopic-amete-alem", "ethioaa"],
["islamicc", "islamic-civil"],
];
for (const [alias, calendar] of aliases) {
const formatter = new Intl.DateTimeFormat("en", { calendar: alias });
const options = formatter.resolvedOptions();
assert.sameValue(options.calendar, calendar, "Resolved alias " + alias);
}