From c97735176ead79b839ccb08c1dfb5dc0c4b4dfec Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Mon, 18 Sep 2023 17:37:19 -0700 Subject: [PATCH] Polyfill: Align ZonedDateTime.p.toPlain{YearMonth,MonthDay} with spec This has been a bug in the polyfill since ZonedDateTime was originally introduced! The spec says to convert the ZonedDateTime to PlainDateTime once here, whereas the polyfill would Get each property in turn. Tests will follow as part of #2519. --- polyfill/lib/zoneddatetime.mjs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/polyfill/lib/zoneddatetime.mjs b/polyfill/lib/zoneddatetime.mjs index 60a6110d95..2938e68616 100644 --- a/polyfill/lib/zoneddatetime.mjs +++ b/polyfill/lib/zoneddatetime.mjs @@ -565,16 +565,18 @@ export class ZonedDateTime { } toPlainYearMonth() { if (!ES.IsTemporalZonedDateTime(this)) throw new TypeError('invalid receiver'); + const dt = dateTime(this); const calendar = GetSlot(this, CALENDAR); const fieldNames = ES.CalendarFields(calendar, ['monthCode', 'year']); - const fields = ES.PrepareTemporalFields(this, fieldNames, []); + const fields = ES.PrepareTemporalFields(dt, fieldNames, []); return ES.CalendarYearMonthFromFields(calendar, fields); } toPlainMonthDay() { if (!ES.IsTemporalZonedDateTime(this)) throw new TypeError('invalid receiver'); + const dt = dateTime(this); const calendar = GetSlot(this, CALENDAR); const fieldNames = ES.CalendarFields(calendar, ['day', 'monthCode']); - const fields = ES.PrepareTemporalFields(this, fieldNames, []); + const fields = ES.PrepareTemporalFields(dt, fieldNames, []); return ES.CalendarMonthDayFromFields(calendar, fields); } getISOFields() {