From 5d5ca83884d9f965a520cdcafc5b7da3aea2fb85 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 6 Nov 2020 16:48:20 -0800 Subject: [PATCH] Specify ZonedDateTime.toPlain{YearMonth,MonthDay}() And make a small adjustment to the polyfill to match. See: #569 --- polyfill/lib/zoneddatetime.mjs | 8 ++++---- spec/zoneddatetime.html | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/polyfill/lib/zoneddatetime.mjs b/polyfill/lib/zoneddatetime.mjs index f7c84be2b0..6c3322445b 100644 --- a/polyfill/lib/zoneddatetime.mjs +++ b/polyfill/lib/zoneddatetime.mjs @@ -657,16 +657,16 @@ export class ZonedDateTime { if (!ES.IsTemporalZonedDateTime(this)) throw new TypeError('invalid receiver'); const YearMonth = GetIntrinsic('%Temporal.PlainYearMonth%'); const calendar = GetSlot(this, CALENDAR); - const fieldNames = ES.CalendarFields(calendar, ['day', 'month', 'year']); - const fields = ES.ToTemporalDateFields(this, fieldNames); + const fieldNames = ES.CalendarFields(calendar, ['month', 'year']); + const fields = ES.ToTemporalYearMonthFields(this, fieldNames); return calendar.yearMonthFromFields(fields, {}, YearMonth); } toPlainMonthDay() { if (!ES.IsTemporalZonedDateTime(this)) throw new TypeError('invalid receiver'); const MonthDay = GetIntrinsic('%Temporal.PlainMonthDay%'); const calendar = GetSlot(this, CALENDAR); - const fieldNames = ES.CalendarFields(calendar, ['day', 'month', 'year']); - const fields = ES.ToTemporalDateFields(this, fieldNames); + const fieldNames = ES.CalendarFields(calendar, ['day', 'month']); + const fields = ES.ToTemporalMonthDayFields(this, fieldNames); return calendar.monthDayFromFields(fields, {}, MonthDay); } getFields() { diff --git a/spec/zoneddatetime.html b/spec/zoneddatetime.html index 0ad03b05e1..7054568f90 100644 --- a/spec/zoneddatetime.html +++ b/spec/zoneddatetime.html @@ -908,7 +908,12 @@

Temporal.ZonedDateTime.prototype.toPlainYearMonth ( )

1. Let _timeZone_ be _zonedDateTime_.[[TimeZone]]. 1. Let _instant_ be ? CreateTemporalInstant(_zonedDateTime_.[[Nanoseconds]]). 1. Let _temporalDateTime_ be ? GetTemporalDateTimeFor(_timeZone_, _instant_). - 1. Return ? create via `calendar.yearMonthFromFields()`. + 1. Let _calendar_ be _zonedDateTime_.[[Calendar]]. + 1. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"month"*, *"year"* »). + 1. Let _fields_ be ? ToTemporalYearMonthFields(_temporalDateTime_, _fieldNames_). + 1. Let _yearMonthFromFields_ be ? Get(_calendar_, *"yearMonthFromFields"*). + 1. Let _options_ be ? OrdinaryObjectCreate(%Object.prototype%). + 1. Return ? Call(_yearMonthFromFields_, _calendar_, « _fields_, _options_, %Temporal.PlainMonthDay% »). @@ -923,7 +928,12 @@

Temporal.ZonedDateTime.prototype.toPlainMonthDay ( )

1. Let _timeZone_ be _zonedDateTime_.[[TimeZone]]. 1. Let _instant_ be ? CreateTemporalInstant(_zonedDateTime_.[[Nanoseconds]]). 1. Let _temporalDateTime_ be ? GetTemporalDateTimeFor(_timeZone_, _instant_). - 1. Return ? create via `calendar.monthDayFromFields()`. + 1. Let _calendar_ be _zonedDateTime_.[[Calendar]]. + 1. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"* »). + 1. Let _fields_ be ? ToTemporalMonthDayFields(_temporalDateTime_, _fieldNames_). + 1. Let _monthDayFromFields_ be ? Get(_calendar_, *"monthDayFromFields"*). + 1. Let _options_ be ? OrdinaryObjectCreate(%Object.prototype%). + 1. Return ? Call(_monthDayFromFields_, _calendar_, « _fields_, _options_, %Temporal.PlainMonthDay% »).