Skip to content

Commit

Permalink
Use calendar to determine time fields in relativeTo property bags
Browse files Browse the repository at this point in the history
This was a straggler from the time calendar support (#522)
  • Loading branch information
ptomato authored and Ms2ger committed Nov 11, 2020
1 parent b12a8c5 commit f58763a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,14 @@ export const ES = ObjectAssign({}, ES2020, {
year = GetSlot(date, ISO_YEAR);
month = GetSlot(date, ISO_MONTH);
day = GetSlot(date, ISO_DAY);
({ hour, minute, second, millisecond, microsecond, nanosecond } = fields);
const TemporalPlainTime = GetIntrinsic('%Temporal.PlainTime%');
const time = calendar.timeFromFields(fields, {}, TemporalPlainTime);
hour = GetSlot(time, ISO_HOUR);
minute = GetSlot(time, ISO_MINUTE);
second = GetSlot(time, ISO_SECOND);
millisecond = GetSlot(time, ISO_MILLISECOND);
microsecond = GetSlot(time, ISO_MICROSECOND);
nanosecond = GetSlot(time, ISO_NANOSECOND);
} else {
({
year,
Expand Down
5 changes: 4 additions & 1 deletion spec/abstractops.html
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,10 @@ <h1>ToRelativeTemporalObject ( _options_ )</h1>
1. Let _dateFromFields_ be ? Get(_calendar_, *"dateFromFields"*).
1. Let _dateOptions_ be ! OrdinaryObjectCreate(%Object.prototype%).
1. Let _temporalDate_ be ? Call(_dateFromFields_, _calendar_, « _fields_, _dateOptions_, %Temporal.PlainDate% »).
1. Return ? CreateTemporalDateTime(_temporalDate_.[[ISOYear]], _temporalDate_.[[ISOMonth]], _temporalDate_.[[ISODay]], _fields_.[[Hour]], _fields_.[[Minute]], _fields_.[[Second]], _fields_.[[Millisecond]], _fields_.[[Microsecond]], _fields_.[[Nanosecond]], _calendar_).
1. Let _timeFromFields_ be ? Get(_calendar_, *"timeFromFields"*).
1. Let _timeOptions_ be ! OrdinaryObjectCreate(%Object.prototype%).
1. Let _temporalTime_ be ? Call(_timeFromFields_, _calendar_, « _fields_, _timeOptions_, %Temporal.PlainTime% »).
1. Return ? CreateTemporalDateTime(_temporalDate_.[[ISOYear]], _temporalDate_.[[ISOMonth]], _temporalDate_.[[ISODay]], _temporalTime_.[[ISOHour]], _temporalTime_.[[ISOMinute]], _temporalTime_.[[ISOSecond]], _temporalTime_.[[ISOMillisecond]], _temporalTime_.[[ISOMicrosecond]], _temporalTime_.[[ISONanosecond]]).
1. Let _string_ be ? ToString(_value_).
1. Let _result_ be ? ParseTemporalDateTimeString(_string_).
1. Let _calendar_ be _result_.[[Calendar]].
Expand Down

0 comments on commit f58763a

Please sign in to comment.