diff --git a/polyfill/lib/ecmascript.mjs b/polyfill/lib/ecmascript.mjs
index c7b5833adb..fc6913f519 100644
--- a/polyfill/lib/ecmascript.mjs
+++ b/polyfill/lib/ecmascript.mjs
@@ -23,7 +23,6 @@ const NumberMaxSafeInteger = Number.MAX_SAFE_INTEGER;
const ObjectCreate = Object.create;
const ObjectDefineProperty = Object.defineProperty;
const ObjectEntries = Object.entries;
-const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
const SetPrototypeHas = Set.prototype.has;
const StringCtor = String;
const StringFromCharCode = String.fromCharCode;
@@ -1136,8 +1135,7 @@ export function PrepareTemporalFields(
fields,
requiredFields,
extraFieldDescriptors = [],
- duplicateBehaviour = 'throw',
- { emptySourceErrorMessage = 'no supported properties found' } = {}
+ duplicateBehaviour = 'throw'
) {
const result = ObjectCreate(null);
let any = false;
@@ -1186,7 +1184,7 @@ export function PrepareTemporalFields(
previousProperty = property;
}
if (requiredFields === 'partial' && !any) {
- throw new TypeError(emptySourceErrorMessage);
+ throw new TypeError('no supported properties found');
}
return result;
}
@@ -1232,19 +1230,19 @@ export function PrepareCalendarFields(calendarRec, bag, calendarFieldNames, nonC
export function ToTemporalTimeRecord(bag, completeness = 'complete') {
const fields = ['hour', 'microsecond', 'millisecond', 'minute', 'nanosecond', 'second'];
- const partial = PrepareTemporalFields(bag, fields, 'partial', undefined, undefined, {
- emptySourceErrorMessage: 'invalid time-like'
- });
- const result = {};
+ let any = false;
+ const result = ObjectCreate(null);
for (let index = 0; index < fields.length; index++) {
const field = fields[index];
- const valueDesc = ObjectGetOwnPropertyDescriptor(partial, field);
- if (valueDesc !== undefined) {
- result[field] = valueDesc.value;
+ const value = bag[field];
+ if (value !== undefined) {
+ result[field] = ToIntegerWithTruncation(value);
+ any = true;
} else if (completeness === 'complete') {
result[field] = 0;
}
}
+ if (!any) throw new TypeError('invalid time-like');
return result;
}
diff --git a/spec/plaintime.html b/spec/plaintime.html
index 5448ac310a..785749eca5 100644
--- a/spec/plaintime.html
+++ b/spec/plaintime.html
@@ -816,35 +816,36 @@
1. If _completeness_ is not present, set _completeness_ to ~complete~.
- 1. Let _partial_ be ? PrepareTemporalFields(_temporalTimeLike_, « *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"nanosecond"*, *"second"* », ~partial~).
1. If _completeness_ is ~complete~, then
1. Let _result_ be a new TemporalTimeLike Record with each field set to 0.
1. Else,
- 1. Let _result_ be a new TemporalTimeLike Record with each field set to *undefined*.
- 1. Let _hourDesc_ be OrdinaryGetOwnProperty(_partial_, *"hour"*).
- 1. If _hourDesc_ is not *undefined*, then
- 1. Assert: _hourDesc_ is a data Property Descriptor.
- 1. Set _result_.[[Hour]] to ℝ(_hourDesc_.[[Value]]).
- 1. Let _minuteDesc_ be OrdinaryGetOwnProperty(_partial_, *"minute"*).
- 1. If _minuteDesc_ is not *undefined*, then
- 1. Assert: _minuteDesc_ is a data Property Descriptor.
- 1. Set _result_.[[Minute]] to ℝ(_minuteDesc_.[[Value]]).
- 1. Let _secondDesc_ be OrdinaryGetOwnProperty(_partial_, *"second"*).
- 1. If _secondDesc_ is not *undefined*, then
- 1. Assert: _secondDesc_ is a data Property Descriptor.
- 1. Set _result_.[[Second]] to ℝ(_secondDesc_.[[Value]]).
- 1. Let _millisecondDesc_ be OrdinaryGetOwnProperty(_partial_, *"millisecond"*).
- 1. If _millisecondDesc_ is not *undefined*, then
- 1. Assert: _millisecondDesc_ is a data Property Descriptor.
- 1. Set _result_.[[Millisecond]] to ℝ(_millisecondDesc_.[[Value]]).
- 1. Let _microsecondDesc_ be OrdinaryGetOwnProperty(_partial_, *"microsecond"*).
- 1. If _microsecondDesc_ is not *undefined*, then
- 1. Assert: _microsecondDesc_ is a data Property Descriptor.
- 1. Set _result_.[[Microsecond]] to ℝ(_microsecondDesc_.[[Value]]).
- 1. Let _nanosecondDesc_ be OrdinaryGetOwnProperty(_partial_, *"nanosecond"*).
- 1. If _nanosecondDesc_ is not *undefined*, then
- 1. Assert: _nanosecondDesc_ is a data Property Descriptor.
- 1. Set _result_.[[Nanosecond]] to ℝ(_nanosecondDesc_.[[Value]]).
+ 1. Let _result_ be a new TemporalTimeLike Record with each field set to ~unset~.
+ 1. Let _any_ be *false*.
+ 1. Let _hour_ be ? Get(_temporalTimeLike_, *"hour"*).
+ 1. If _hour_ is not *undefined*, then
+ 1. Set _result_.[[Hour]] to ? ToIntegerWithTruncation(_hour_).
+ 1. Set _any_ to *true*.
+ 1. Let _microsecond_ be ? Get(_temporalTimeLike_, *"microsecond"*).
+ 1. If _microsecond_ is not *undefined*, then
+ 1. Set _result_.[[Microsecond]] to ? ToIntegerWithTruncation(_microsecond_).
+ 1. Set _any_ to *true*.
+ 1. Let _millisecond_ be ? Get(_temporalTimeLike_, *"millisecond"*).
+ 1. If _millisecond_ is not *undefined*, then
+ 1. Set _result_.[[Millisecond]] to ? ToIntegerWithTruncation(_millisecond_).
+ 1. Set _any_ to *true*.
+ 1. Let _minute_ be ? Get(_temporalTimeLike_, *"minute"*).
+ 1. If _minute_ is not *undefined*, then
+ 1. Set _result_.[[Minute]] to ? ToIntegerWithTruncation(_minute_).
+ 1. Set _any_ to *true*.
+ 1. Let _nanosecond_ be ? Get(_temporalTimeLike_, *"nanosecond"*).
+ 1. If _nanosecond_ is not *undefined*, then
+ 1. Set _result_.[[Nanosecond]] to ? ToIntegerWithTruncation(_nanosecond_).
+ 1. Set _any_ to *true*.
+ 1. Let _second_ be ? Get(_temporalTimeLike_, *"second"*).
+ 1. If _second_ is not *undefined*, then
+ 1. Set _result_.[[Second]] to ? ToIntegerWithTruncation(_second_).
+ 1. Set _any_ to *true*.
+ 1. If _any_ is *false*, throw a *TypeError* exception.
1. Return _result_.