Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normative: Consistently check overflow options #2225

Merged
merged 1 commit into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,13 +1023,15 @@ export const ES = ObjectAssign({}, ES2020, {
if (ES.Type(item) === 'Object') {
if (ES.IsTemporalDate(item)) return item;
if (ES.IsTemporalZonedDateTime(item)) {
ES.ToTemporalOverflow(options); // validate and ignore
item = ES.BuiltinTimeZoneGetPlainDateTimeFor(
GetSlot(item, TIME_ZONE),
GetSlot(item, INSTANT),
GetSlot(item, CALENDAR)
);
}
if (ES.IsTemporalDateTime(item)) {
ES.ToTemporalOverflow(options); // validate and ignore
return ES.CreateTemporalDate(
GetSlot(item, ISO_YEAR),
GetSlot(item, ISO_MONTH),
Expand Down Expand Up @@ -1071,13 +1073,15 @@ export const ES = ObjectAssign({}, ES2020, {
if (ES.Type(item) === 'Object') {
if (ES.IsTemporalDateTime(item)) return item;
if (ES.IsTemporalZonedDateTime(item)) {
ES.ToTemporalOverflow(options); // validate and ignore
return ES.BuiltinTimeZoneGetPlainDateTimeFor(
GetSlot(item, TIME_ZONE),
GetSlot(item, INSTANT),
GetSlot(item, CALENDAR)
);
}
if (ES.IsTemporalDate(item)) {
ES.ToTemporalOverflow(options); // validate and ignore
return ES.CreateTemporalDateTime(
GetSlot(item, ISO_YEAR),
GetSlot(item, ISO_MONTH),
Expand Down
2 changes: 2 additions & 0 deletions spec/plaindate.html
Original file line number Diff line number Diff line change
Expand Up @@ -710,10 +710,12 @@ <h1>ToTemporalDate ( _item_ [ , _options_ ] )</h1>
1. If _item_ has an [[InitializedTemporalDate]] internal slot, then
1. Return _item_.
1. If _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then
1. Perform ? ToTemporalOverflow(_options_).
1. Let _instant_ be ! CreateTemporalInstant(_item_.[[Nanoseconds]]).
1. Let _plainDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]).
1. Return ! CreateTemporalDate(_plainDateTime_.[[ISOYear]], _plainDateTime_.[[ISOMonth]], _plainDateTime_.[[ISODay]], _plainDateTime_.[[Calendar]]).
1. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then
1. Perform ? ToTemporalOverflow(_options_).
1. Return ! CreateTemporalDate(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], _item_.[[Calendar]]).
1. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_).
1. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »).
Expand Down
2 changes: 2 additions & 0 deletions spec/plaindatetime.html
Original file line number Diff line number Diff line change
Expand Up @@ -899,9 +899,11 @@ <h1>ToTemporalDateTime ( _item_ [ , _options_ ] )</h1>
1. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then
1. Return _item_.
1. If _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then
1. Perform ? ToTemporalOverflow(_options_).
1. Let _instant_ be ! CreateTemporalInstant(_item_.[[Nanoseconds]]).
1. Return ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]).
1. If _item_ has an [[InitializedTemporalDate]] internal slot, then
1. Perform ? ToTemporalOverflow(_options_).
1. Return ? CreateTemporalDateTime(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], 0, 0, 0, 0, 0, 0, _item_.[[Calendar]]).
1. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_).
1. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"month"*, *"monthCode"*, *"nanosecond"*, *"second"*, *"year"* »).
Expand Down