From 54f79f6bb75c7a96aa8163ab67588da1e3cc27db Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Mon, 19 Aug 2024 17:07:40 -0700 Subject: [PATCH] Polyfill: Make Duration.p.with() conform to spec The spec text uses ToTemporalPartialDurationRecord here, not PrepareTemporalFields. This is relevant because we are going to refactor PrepareTemporalFields as part of #2925. --- polyfill/lib/duration.mjs | 19 ++----------------- polyfill/lib/ecmascript.mjs | 10 ---------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/polyfill/lib/duration.mjs b/polyfill/lib/duration.mjs index d7ec5a4e79..e710b60c69 100644 --- a/polyfill/lib/duration.mjs +++ b/polyfill/lib/duration.mjs @@ -160,23 +160,8 @@ export class Duration { } with(durationLike) { if (!ES.IsTemporalDuration(this)) throw new TypeError('invalid receiver'); - const partialDuration = ES.PrepareTemporalFields( - durationLike, - [ - 'days', - 'hours', - 'microseconds', - 'milliseconds', - 'minutes', - 'months', - 'nanoseconds', - 'seconds', - 'weeks', - 'years' - ], - 'partial' - ); - let { + const partialDuration = ES.ToTemporalPartialDurationRecord(durationLike); + const { years = GetSlot(this, YEARS), months = GetSlot(this, MONTHS), weeks = GetSlot(this, WEEKS), diff --git a/polyfill/lib/ecmascript.mjs b/polyfill/lib/ecmascript.mjs index ac1cb554a4..c7b5833adb 100644 --- a/polyfill/lib/ecmascript.mjs +++ b/polyfill/lib/ecmascript.mjs @@ -229,16 +229,6 @@ const BUILTIN_CASTS = new Map([ ['millisecond', ToIntegerWithTruncation], ['microsecond', ToIntegerWithTruncation], ['nanosecond', ToIntegerWithTruncation], - ['years', ToIntegerIfIntegral], - ['months', ToIntegerIfIntegral], - ['weeks', ToIntegerIfIntegral], - ['days', ToIntegerIfIntegral], - ['hours', ToIntegerIfIntegral], - ['minutes', ToIntegerIfIntegral], - ['seconds', ToIntegerIfIntegral], - ['milliseconds', ToIntegerIfIntegral], - ['microseconds', ToIntegerIfIntegral], - ['nanoseconds', ToIntegerIfIntegral], ['offset', ToPrimitiveAndRequireString] ]);