Skip to content

Commit 668cea1

Browse files
ptomato12wrigja
authored andcommitted
Fix observable call of CalendarDateFromFields in DifferenceTemporalPlainYearMonth
The reference code was out of line with the spec text here, which says that CalendarDateFromFields must be called the first time before the second call to DifferenceTemporalPlainYearMonth. These are observable. See also tc39/proposal-temporal#2252 UPSTREAM_COMMIT=7afcd5d2a49cd38cafac710f394b3c60232fa0a6
1 parent 12df4ec commit 668cea1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/ecmascript.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4627,12 +4627,12 @@ export function DifferenceTemporalPlainYearMonth(
46274627
const fieldNames = CalendarFields(calendar, ['monthCode', 'year'] as const);
46284628
const otherFields = PrepareTemporalFields(other, fieldNames, []);
46294629
otherFields.day = 1;
4630-
const thisFields = PrepareTemporalFields(yearMonth, fieldNames, []);
4631-
thisFields.day = 1;
46324630
// The calls to PrepareTemporalFields don't mark day as a required property,
46334631
// and TS doesn't automatically narrow the type of the object because of the
46344632
// assignments above, so we must "cast" the inputs.
46354633
const otherDate = CalendarDateFromFields(calendar, otherFields as typeof otherFields & { day: number });
4634+
const thisFields = PrepareTemporalFields(yearMonth, fieldNames, []);
4635+
thisFields.day = 1;
46364636
const thisDate = CalendarDateFromFields(calendar, thisFields as typeof thisFields & { day: number });
46374637

46384638
const untilOptions = MergeLargestUnitOption(options, largestUnit);

0 commit comments

Comments
 (0)