Skip to content

Commit 12df4ec

Browse files
ptomato12wrigja
authored andcommitted
Fix observable call of ToRelativeTemporalObject in Duration.p.total
The reference code was out of line with the spec text here, which says that ToRelativeTemporalObject must be called before GetTemporalUnit. Both calls are observable. See also tc39/proposal-temporal#2252 UPSTREAM_COMMIT=5644cbd89a65cd4264c80e59c03c7bdea06f4821
1 parent 166654e commit 12df4ec

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/duration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,8 @@ export class Duration implements Temporal.Duration {
334334
typeof optionsParam === 'string'
335335
? (ES.CreateOnePropObject('unit', optionsParam) as Exclude<typeof optionsParam, string>)
336336
: ES.GetOptionsObject(optionsParam);
337-
const unit = ES.GetTemporalUnit(options, 'unit', 'datetime', ES.REQUIRED);
338337
const relativeTo = ES.ToRelativeTemporalObject(options);
338+
const unit = ES.GetTemporalUnit(options, 'unit', 'datetime', ES.REQUIRED);
339339

340340
// Convert larger units down to days
341341
({ years, months, weeks, days } = ES.UnbalanceDurationRelative(years, months, weeks, days, unit, relativeTo));

0 commit comments

Comments
 (0)