commit f1bdaf7092cdd41f6c1c8649ad76e5ee335166b3
parent 15b8a42861a16fdd97bc1cefd8119d73b1d9f6f4
Author: André Bargull <andre.bargull@gmail.com>
Date: Fri, 28 Nov 2025 07:47:10 +0000
Bug 1999918: Update NonISOResolveFields to handle "month" correctly. r=spidermonkey-reviewers,mgaudet
Requested in <https://github.com/tc39/proposal-intl-era-monthcode/issues/90> to
improve the spec to make this more clear.
Test262 coverage:
- https://github.com/tc39/test262/pull/4708
- https://github.com/tc39/test262/pull/4723
Differential Revision: https://phabricator.services.mozilla.com/D274334
Diffstat:
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/js/src/builtin/temporal/Calendar.cpp b/js/src/builtin/temporal/Calendar.cpp
@@ -2357,14 +2357,6 @@ static bool NonISOMonthDayToISOReferenceDate(JSContext* cx, CalendarId calendar,
return false;
}
- // |month| and |monthCode| must be consistent.
- if (month.code != MonthCode{} && month.ordinal > 0) {
- if (!CalendarFieldMonthCodeMatchesMonth(cx, fields, date.get(),
- month.ordinal)) {
- return false;
- }
- }
-
*result = ToISODate(date.get());
return true;
}
@@ -2432,8 +2424,11 @@ static bool NonISOResolveFields(JSContext* cx, CalendarId calendar,
// Date and Year-Month require |year| (or |eraYear|) to be present.
// Month-Day requires |year| (or |eraYear|) if |monthCode| is absent.
+ // Month-Day requires |year| (or |eraYear|) if |month| is present, even if
+ // |monthCode| is also present.
bool requireYear = type == FieldType::Date || type == FieldType::YearMonth ||
- !fields.has(CalendarField::MonthCode);
+ !fields.has(CalendarField::MonthCode) ||
+ fields.has(CalendarField::Month);
// Determine if any calendar fields are missing.
const char* missingField = nullptr;