diff --git a/polyfill/lib/ecmascript.mjs b/polyfill/lib/ecmascript.mjs
index ca303e4341..5deeda16c9 100644
--- a/polyfill/lib/ecmascript.mjs
+++ b/polyfill/lib/ecmascript.mjs
@@ -1160,6 +1160,7 @@ export function ToTemporalTimeRecord(bag, completeness = 'complete') {
}
export function ToTemporalDate(item, options) {
+ if (options !== undefined) options = SnapshotOwnProperties(GetOptionsObject(options), null);
if (Type(item) === 'Object') {
if (IsTemporalDate(item)) return item;
if (IsTemporalZonedDateTime(item)) {
@@ -1180,12 +1181,12 @@ export function ToTemporalDate(item, options) {
const fields = PrepareTemporalFields(item, fieldNames, []);
return CalendarDateFromFields(calendar, fields, options);
}
- ToTemporalOverflow(options); // validate and ignore
let { year, month, day, calendar, z } = ParseTemporalDateString(RequireString(item));
if (z) throw new RangeError('Z designator not supported for PlainDate');
if (!calendar) calendar = 'iso8601';
if (!IsBuiltinCalendar(calendar)) throw new RangeError(`invalid calendar identifier ${calendar}`);
calendar = ASCIILowercase(calendar);
+ ToTemporalOverflow(options); // validate and ignore
return CreateTemporalDate(year, month, day, calendar);
}
@@ -1290,6 +1291,7 @@ export function ToTemporalInstant(item) {
}
export function ToTemporalMonthDay(item, options) {
+ if (options !== undefined) options = SnapshotOwnProperties(GetOptionsObject(options), null);
if (Type(item) === 'Object') {
if (IsTemporalMonthDay(item)) return item;
let calendar, calendarAbsent;
@@ -1313,11 +1315,11 @@ export function ToTemporalMonthDay(item, options) {
return CalendarMonthDayFromFields(calendar, fields, options);
}
- ToTemporalOverflow(options); // validate and ignore
let { month, day, referenceISOYear, calendar } = ParseTemporalMonthDayString(RequireString(item));
if (calendar === undefined) calendar = 'iso8601';
if (!IsBuiltinCalendar(calendar)) throw new RangeError(`invalid calendar identifier ${calendar}`);
calendar = ASCIILowercase(calendar);
+ ToTemporalOverflow(options); // validate and ignore
if (referenceISOYear === undefined) {
RejectISODate(1972, month, day);
@@ -1364,6 +1366,7 @@ export function ToTemporalTime(item, overflow = 'constrain') {
}
export function ToTemporalYearMonth(item, options) {
+ if (options !== undefined) options = SnapshotOwnProperties(GetOptionsObject(options), null);
if (Type(item) === 'Object') {
if (IsTemporalYearMonth(item)) return item;
const calendar = GetTemporalCalendarSlotValueWithISODefault(item);
@@ -1372,11 +1375,11 @@ export function ToTemporalYearMonth(item, options) {
return CalendarYearMonthFromFields(calendar, fields, options);
}
- ToTemporalOverflow(options); // validate and ignore
let { year, month, referenceISODay, calendar } = ParseTemporalYearMonthString(RequireString(item));
if (calendar === undefined) calendar = 'iso8601';
if (!IsBuiltinCalendar(calendar)) throw new RangeError(`invalid calendar identifier ${calendar}`);
calendar = ASCIILowercase(calendar);
+ ToTemporalOverflow(options); // validate and ignore
if (referenceISODay === undefined) {
RejectISODate(year, month, 1);
diff --git a/polyfill/lib/plaindate.mjs b/polyfill/lib/plaindate.mjs
index 7b2293b473..b65fc60396 100644
--- a/polyfill/lib/plaindate.mjs
+++ b/polyfill/lib/plaindate.mjs
@@ -95,7 +95,7 @@ export class PlainDate {
throw new TypeError('invalid argument');
}
ES.RejectTemporalLikeObject(temporalDateLike);
- options = ES.GetOptionsObject(options);
+ const resolvedOptions = ES.SnapshotOwnProperties(ES.GetOptionsObject(options), null);
const calendar = GetSlot(this, CALENDAR);
const fieldNames = ES.CalendarFields(calendar, ['day', 'month', 'monthCode', 'year']);
@@ -104,7 +104,7 @@ export class PlainDate {
fields = ES.CalendarMergeFields(calendar, fields, partialDate);
fields = ES.PrepareTemporalFields(fields, fieldNames, []);
- return ES.CalendarDateFromFields(calendar, fields, options);
+ return ES.CalendarDateFromFields(calendar, fields, resolvedOptions);
}
withCalendar(calendar) {
if (!ES.IsTemporalDate(this)) throw new TypeError('invalid receiver');
diff --git a/polyfill/lib/plainmonthday.mjs b/polyfill/lib/plainmonthday.mjs
index 5f4cf9c6d2..8b2fe4c91e 100644
--- a/polyfill/lib/plainmonthday.mjs
+++ b/polyfill/lib/plainmonthday.mjs
@@ -35,7 +35,7 @@ export class PlainMonthDay {
throw new TypeError('invalid argument');
}
ES.RejectTemporalLikeObject(temporalMonthDayLike);
- options = ES.GetOptionsObject(options);
+ const resolvedOptions = ES.SnapshotOwnProperties(ES.GetOptionsObject(options), null);
const calendar = GetSlot(this, CALENDAR);
const fieldNames = ES.CalendarFields(calendar, ['day', 'month', 'monthCode', 'year']);
@@ -44,7 +44,7 @@ export class PlainMonthDay {
fields = ES.CalendarMergeFields(calendar, fields, partialMonthDay);
fields = ES.PrepareTemporalFields(fields, fieldNames, []);
- return ES.CalendarMonthDayFromFields(calendar, fields, options);
+ return ES.CalendarMonthDayFromFields(calendar, fields, resolvedOptions);
}
equals(other) {
if (!ES.IsTemporalMonthDay(this)) throw new TypeError('invalid receiver');
diff --git a/polyfill/lib/plainyearmonth.mjs b/polyfill/lib/plainyearmonth.mjs
index f465982f1a..df5d2268e3 100644
--- a/polyfill/lib/plainyearmonth.mjs
+++ b/polyfill/lib/plainyearmonth.mjs
@@ -61,7 +61,7 @@ export class PlainYearMonth {
throw new TypeError('invalid argument');
}
ES.RejectTemporalLikeObject(temporalYearMonthLike);
- options = ES.GetOptionsObject(options);
+ const resolvedOptions = ES.SnapshotOwnProperties(ES.GetOptionsObject(options), null);
const calendar = GetSlot(this, CALENDAR);
const fieldNames = ES.CalendarFields(calendar, ['month', 'monthCode', 'year']);
@@ -70,7 +70,7 @@ export class PlainYearMonth {
fields = ES.CalendarMergeFields(calendar, fields, partialYearMonth);
fields = ES.PrepareTemporalFields(fields, fieldNames, []);
- return ES.CalendarYearMonthFromFields(calendar, fields, options);
+ return ES.CalendarYearMonthFromFields(calendar, fields, resolvedOptions);
}
add(temporalDurationLike, options = undefined) {
if (!ES.IsTemporalYearMonth(this)) throw new TypeError('invalid receiver');
diff --git a/spec/plaindate.html b/spec/plaindate.html
index f21f4c12e7..5e529ffe31 100644
--- a/spec/plaindate.html
+++ b/spec/plaindate.html
@@ -407,14 +407,14 @@
Temporal.PlainDate.prototype.with ( _temporalDateLike_ [ , _options_ ] )
@@ -740,6 +740,7 @@ ToTemporalDate ( _item_ [ , _options_ ] )
1. If _options_ is not present, set _options_ to *undefined*.
1. Assert: Type(_options_) is Object or Undefined.
+ 1. If _options_ is not *undefined*, set _options_ to ? SnapshotOwnProperties(? GetOptionsObject(_options_), *null*).
1. If Type(_item_) is Object, then
1. If _item_ has an [[InitializedTemporalDate]] internal slot, then
1. Return _item_.
@@ -755,7 +756,6 @@ ToTemporalDate ( _item_ [ , _options_ ] )
1. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »).
1. Let _fields_ be ? PrepareTemporalFields(_item_, _fieldNames_, «»).
1. Return ? CalendarDateFromFields(_calendar_, _fields_, _options_).
- 1. Perform ? ToTemporalOverflow(_options_).
1. If _item_ is not a String, throw a *TypeError* exception.
1. Let _result_ be ? ParseTemporalDateString(_item_).
1. Assert: IsValidISODate(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]]) is *true*.
@@ -763,6 +763,7 @@ ToTemporalDate ( _item_ [ , _options_ ] )
1. If _calendar_ is *undefined*, set _calendar_ to *"iso8601"*.
1. If IsBuiltinCalendar(_calendar_) is *false*, throw a *RangeError* exception.
1. Set _calendar_ to the ASCII-lowercase of _calendar_.
+ 1. Perform ? ToTemporalOverflow(_options_).
1. Return ? CreateTemporalDate(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _calendar_).
diff --git a/spec/plainmonthday.html b/spec/plainmonthday.html
index ad45552a97..1798319114 100644
--- a/spec/plainmonthday.html
+++ b/spec/plainmonthday.html
@@ -150,14 +150,14 @@ Temporal.PlainMonthDay.prototype.with ( _temporalMonthDayLike_ [ , _options_
1. If Type(_temporalMonthDayLike_) is not Object, then
1. Throw a *TypeError* exception.
1. Perform ? RejectTemporalLikeObject(_temporalMonthDayLike_).
- 1. Set _options_ to ? GetOptionsObject(_options_).
+ 1. Let _resolvedOptions_ be ? SnapshotOwnProperties(? GetOptionsObject(_options_), *null*).
1. Let _calendar_ be _monthDay_.[[Calendar]].
1. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »).
1. Let _fields_ be ? PrepareTemporalFields(_monthDay_, _fieldNames_, «»).
1. Let _partialMonthDay_ be ? PrepareTemporalFields(_temporalMonthDayLike_, _fieldNames_, ~partial~).
1. Set _fields_ to ? CalendarMergeFields(_calendar_, _fields_, _partialMonthDay_).
1. Set _fields_ to ? PrepareTemporalFields(_fields_, _fieldNames_, «»).
- 1. Return ? CalendarMonthDayFromFields(_calendar_, _fields_, _options_).
+ 1. Return ? CalendarMonthDayFromFields(_calendar_, _fields_, _resolvedOptions_).
@@ -360,6 +360,7 @@ ToTemporalMonthDay ( _item_ [ , _options_ ] )
1. If _options_ is not present, set _options_ to *undefined*.
1. Assert: Type(_options_) is Object or Undefined.
+ 1. If _options_ is not *undefined*, set _options_ to ? SnapshotOwnProperties(? GetOptionsObject(_options_), *null*).
1. Let _referenceISOYear_ be 1972 (the first leap year after the Unix epoch).
1. If Type(_item_) is Object, then
1. If _item_ has an [[InitializedTemporalMonthDay]] internal slot, then
@@ -382,13 +383,13 @@ ToTemporalMonthDay ( _item_ [ , _options_ ] )
1. If _calendarAbsent_ is *true*, and _month_ is not *undefined*, and _monthCode_ is *undefined* and _year_ is *undefined*, then
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"year"*, 𝔽(_referenceISOYear_)).
1. Return ? CalendarMonthDayFromFields(_calendar_, _fields_, _options_).
- 1. Perform ? ToTemporalOverflow(_options_).
1. If _item_ is not a String, throw a *TypeError* exception.
1. Let _result_ be ? ParseTemporalMonthDayString(_item_).
1. Let _calendar_ be _result_.[[Calendar]].
1. If _calendar_ is *undefined*, set _calendar_ to *"iso8601"*.
1. If IsBuiltinCalendar(_calendar_) is *false*, throw a *RangeError* exception.
1. Set _calendar_ to the ASCII-lowercase of _calendar_.
+ 1. Perform ? ToTemporalOverflow(_options_).
1. If _result_.[[Year]] is *undefined*, then
1. Return ? CreateTemporalMonthDay(_result_.[[Month]], _result_.[[Day]], _calendar_, _referenceISOYear_).
1. Set _result_ to ? CreateTemporalMonthDay(_result_.[[Month]], _result_.[[Day]], _calendar_, result.[[year]]).
diff --git a/spec/plainyearmonth.html b/spec/plainyearmonth.html
index 5ae9922c06..e69a74ca50 100644
--- a/spec/plainyearmonth.html
+++ b/spec/plainyearmonth.html
@@ -231,14 +231,14 @@ Temporal.PlainYearMonth.prototype.with ( _temporalYearMonthLike_ [ , _option
1. If Type(_temporalYearMonthLike_) is not Object, then
1. Throw a *TypeError* exception.
1. Perform ? RejectTemporalLikeObject(_temporalYearMonthLike_).
- 1. Set _options_ to ? GetOptionsObject(_options_).
+ 1. Let _resolvedOptions_ be ? SnapshotOwnProperties(? GetOptionsObject(_options_), *null*).
1. Let _calendar_ be _yearMonth_.[[Calendar]].
1. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"month"*, *"monthCode"*, *"year"* »).
1. Let _fields_ be ? PrepareTemporalFields(_yearMonth_, _fieldNames_, «»).
1. Let _partialYearMonth_ be ? PrepareTemporalFields(_temporalYearMonthLike_, _fieldNames_, ~partial~).
1. Set _fields_ to ? CalendarMergeFields(_calendar_, _fields_, _partialYearMonth_).
1. Set _fields_ to ? PrepareTemporalFields(_fields_, _fieldNames_, «»).
- 1. Return ? CalendarYearMonthFromFields(_calendar_, _fields_, _options_).
+ 1. Return ? CalendarYearMonthFromFields(_calendar_, _fields_, _resolvedOptions_).
@@ -489,6 +489,7 @@ ToTemporalYearMonth ( _item_ [ , _options_ ] )
1. If _options_ is not present, set _options_ to *undefined*.
1. Assert: Type(_options_) is Object or Undefined.
+ 1. If _options_ is not *undefined*, set _options_ to ? SnapshotOwnProperties(? GetOptionsObject(_options_), *null*).
1. If Type(_item_) is Object, then
1. If _item_ has an [[InitializedTemporalYearMonth]] internal slot, then
1. Return _item_.
@@ -496,13 +497,13 @@ ToTemporalYearMonth ( _item_ [ , _options_ ] )
1. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"month"*, *"monthCode"*, *"year"* »).
1. Let _fields_ be ? PrepareTemporalFields(_item_, _fieldNames_, «»).
1. Return ? CalendarYearMonthFromFields(_calendar_, _fields_, _options_).
- 1. Perform ? ToTemporalOverflow(_options_).
1. If _item_ is not a String, throw a *TypeError* exception.
1. Let _result_ be ? ParseTemporalYearMonthString(_item_).
1. Let _calendar_ be _result_.[[Calendar]].
1. If _calendar_ is *undefined*, set _calendar_ to *"iso8601"*.
1. If IsBuiltinCalendar(_calendar_) is *false*, throw a *RangeError* exception.
1. Set _calendar_ to the ASCII-lowercase of _calendar_.
+ 1. Perform ? ToTemporalOverflow(_options_).
1. Set _result_ to ? CreateTemporalYearMonth(_result_.[[Year]], _result_.[[Month]], _calendar_, _result_.[[Day]]).
1. NOTE: The following operation is called without _options_, in order for the calendar to store a canonical value in the [[ISODay]] internal slot of the result.
1. Return ? CalendarYearMonthFromFields(_calendar_, _result_).