@@ -662,9 +662,9 @@ JSValue TemporalDuration::compare(JSGlobalObject* globalObject, JSValue valueOne
662662 // Fast path: no ZDT addZonedDateTime needed — pure 24h-day time comparison.
663663 bool hasCalendarUnits = one->years () || two->years () || one->months () || two->months () || one->weeks () || two->weeks ();
664664 if (!hasCalendarUnits) {
665- auto timeDuration1 = add24HourDaysToTimeDuration (globalObject, toInternalDuration (one->m_duration ).time (), one->days ());
665+ auto timeDuration1 = add24HourDaysToTimeDuration (globalObject, TemporalCore:: toInternalDuration (one->m_duration ).time (), one->days ());
666666 RETURN_IF_EXCEPTION (scope, { });
667- auto timeDuration2 = add24HourDaysToTimeDuration (globalObject, toInternalDuration (two->m_duration ).time (), two->days ());
667+ auto timeDuration2 = add24HourDaysToTimeDuration (globalObject, TemporalCore:: toInternalDuration (two->m_duration ).time (), two->days ());
668668 RETURN_IF_EXCEPTION (scope, { });
669669 return jsNumber (timeDuration1 > timeDuration2 ? 1 : timeDuration1 < timeDuration2 ? -1 : 0 );
670670 }
@@ -681,14 +681,14 @@ JSValue TemporalDuration::compare(JSGlobalObject* globalObject, JSValue valueOne
681681 auto endDate1 = calendarAwareDateAdd (globalObject, relativeTo.calendarId , plainDate, dateDuration1, TemporalOverflow::Constrain);
682682 RETURN_IF_EXCEPTION (scope, { });
683683 auto daysDiff1 = TemporalCore::diffISODate (plainDate, endDate1, TemporalUnit::Day);
684- auto timeDuration1 = add24HourDaysToTimeDuration (globalObject, toInternalDuration (one->m_duration ).time (), daysDiff1.days ());
684+ auto timeDuration1 = add24HourDaysToTimeDuration (globalObject, TemporalCore:: toInternalDuration (one->m_duration ).time (), daysDiff1.days ());
685685 RETURN_IF_EXCEPTION (scope, { });
686686
687687 ISO8601 ::Duration dateDuration2 (two->years (), two->months (), two->weeks (), two->days (), 0LL , 0LL , 0LL , 0LL , Int128 (0 ), Int128 (0 ));
688688 auto endDate2 = calendarAwareDateAdd (globalObject, relativeTo.calendarId , plainDate, dateDuration2, TemporalOverflow::Constrain);
689689 RETURN_IF_EXCEPTION (scope, { });
690690 auto daysDiff2 = TemporalCore::diffISODate (plainDate, endDate2, TemporalUnit::Day);
691- auto timeDuration2 = add24HourDaysToTimeDuration (globalObject, toInternalDuration (two->m_duration ).time (), daysDiff2.days ());
691+ auto timeDuration2 = add24HourDaysToTimeDuration (globalObject, TemporalCore:: toInternalDuration (two->m_duration ).time (), daysDiff2.days ());
692692 RETURN_IF_EXCEPTION (scope, { });
693693
694694 return jsNumber (timeDuration1 > timeDuration2 ? 1 : timeDuration1 < timeDuration2 ? -1 : 0 );
@@ -805,26 +805,14 @@ ISO8601::Duration TemporalDuration::add(JSGlobalObject* globalObject, JSValue ot
805805 }
806806
807807 auto result = ISO8601::InternalDuration::combineDateAndTimeDuration (ISO8601::Duration (), timeResult);
808- auto durResult = temporalDurationFromInternal (result, largestUnit);
808+ auto durResult = TemporalCore:: temporalDurationFromInternal (result, largestUnit);
809809 if (!durResult) [[unlikely]] {
810810 throwTemporalError (globalObject, scope, durResult.error ());
811811 return { };
812812 }
813813 return *durResult;
814814}
815815
816- // https://tc39.es/proposal-temporal/#sec-temporal-tointernaldurationrecord
817- ISO8601 ::InternalDuration TemporalDuration::toInternalDuration (ISO8601 ::Duration d)
818- {
819- return TemporalCore::toInternalDuration (d);
820- }
821-
822- // https://tc39.es/proposal-temporal/#sec-temporal-temporaldurationfrominternal
823- TemporalResult<ISO8601 ::Duration> TemporalDuration::temporalDurationFromInternal (ISO8601 ::InternalDuration internalDuration, TemporalUnit largestUnit)
824- {
825- return TemporalCore::temporalDurationFromInternal (internalDuration, largestUnit);
826- }
827-
828816// https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype.subtract
829817// Spec: Duration.prototype.subtract(other) — no relativeTo; throws RangeError if calendar units present.
830818ISO8601 ::Duration TemporalDuration::subtract (JSGlobalObject* globalObject, JSValue otherValue) const
@@ -845,12 +833,6 @@ std::tuple<ISO8601::PlainDate, ISO8601::PlainTime> TemporalDuration::combineISOD
845833 return { isoDate, isoTime };
846834}
847835
848- // Local wrapper: tuple-form getUTCEpochNanoseconds delegates to TemporalCore two-arg form.
849- // https://tc39.es/proposal-temporal/#sec-temporal-getutcepochnanoseconds
850- Int128 getUTCEpochNanoseconds (std::tuple<ISO8601 ::PlainDate, ISO8601 ::PlainTime> isoDateTime)
851- {
852- return TemporalCore::getUTCEpochNanoseconds (std::get<0 >(isoDateTime), std::get<1 >(isoDateTime));
853- }
854836
855837// RoundDuration ( years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, increment, unit, roundingMode [ , relativeTo ] )
856838// https://tc39.es/proposal-temporal/#sec-temporal-roundduration
@@ -1015,7 +997,7 @@ ISO8601::Duration TemporalDuration::round(JSGlobalObject* globalObject, JSValue
1015997 RETURN_IF_EXCEPTION (scope, { });
1016998 zdtInternal = round (globalObject, zdtInternal, roundingIncrement, smallestUnit, roundingMode);
1017999 RETURN_IF_EXCEPTION (scope, { });
1018- auto durResult = temporalDurationFromInternal (zdtInternal, largestUnit);
1000+ auto durResult = TemporalCore:: temporalDurationFromInternal (zdtInternal, largestUnit);
10191001 if (!durResult) [[unlikely]] {
10201002 throwTemporalError (globalObject, scope, durResult.error ());
10211003 return { };
@@ -1030,7 +1012,7 @@ ISO8601::Duration TemporalDuration::round(JSGlobalObject* globalObject, JSValue
10301012 }
10311013 // Step 27 sub-step: If TemporalUnitCategory(largestUnit) is ~date~, set largestUnit to ~hour~.
10321014 TemporalUnit effectiveLargestUnit = (largestUnit <= TemporalUnit::Day) ? TemporalUnit::Hour : largestUnit;
1033- auto durResult = temporalDurationFromInternal (*zdtDiffResult, effectiveLargestUnit);
1015+ auto durResult = TemporalCore:: temporalDurationFromInternal (*zdtDiffResult, effectiveLargestUnit);
10341016 if (!durResult) [[unlikely]] {
10351017 throwTemporalError (globalObject, scope, durResult.error ());
10361018 return { };
@@ -1066,7 +1048,7 @@ ISO8601::Duration TemporalDuration::round(JSGlobalObject* globalObject, JSValue
10661048 }
10671049
10681050 // Step 28i: Return ? TemporalDurationFromInternal(internalDuration, largestUnit).
1069- auto durResult = temporalDurationFromInternal (*diffResult, largestUnit);
1051+ auto durResult = TemporalCore:: temporalDurationFromInternal (*diffResult, largestUnit);
10701052 if (!durResult) [[unlikely]] {
10711053 throwTemporalError (globalObject, scope, durResult.error ());
10721054 return { };
@@ -1090,7 +1072,7 @@ ISO8601::Duration TemporalDuration::round(JSGlobalObject* globalObject, JSValue
10901072 RETURN_IF_EXCEPTION (scope, { });
10911073 auto result = round (globalObject, internalDuration, roundingIncrement, smallestUnit, roundingMode);
10921074 RETURN_IF_EXCEPTION (scope, { });
1093- auto durResult2 = temporalDurationFromInternal (result, largestUnit);
1075+ auto durResult2 = TemporalCore:: temporalDurationFromInternal (result, largestUnit);
10941076 if (!durResult2) [[unlikely]] {
10951077 throwTemporalError (globalObject, scope, durResult2.error ());
10961078 return { };
@@ -1205,8 +1187,8 @@ double TemporalDuration::total(JSGlobalObject* globalObject, JSValue optionsValu
12051187 RETURN_IF_EXCEPTION (scope, 0 );
12061188 ISO8601 ::PlainTime targetTime = TemporalCore::plainTimeFromSubdayNs (subdayNs);
12071189
1208- Int128 originEpochNs = getUTCEpochNanoseconds (combineISODateAndTimeRecord ( plainDate, midnight) );
1209- Int128 destEpochNs = getUTCEpochNanoseconds (combineISODateAndTimeRecord ( targetDate, targetTime) );
1190+ Int128 originEpochNs = TemporalCore:: getUTCEpochNanoseconds (plainDate, midnight);
1191+ Int128 destEpochNs = TemporalCore:: getUTCEpochNanoseconds (targetDate, targetTime);
12101192
12111193 // Spec: DifferencePlainDateTimeWithTotal early-return for zero duration,
12121194 // then ISODateTimeWithinLimits check on both endpoints.
@@ -1298,7 +1280,7 @@ String TemporalDuration::toString(JSGlobalObject* globalObject, JSValue optionsV
12981280 // Step 17: Let roundedDuration be ? TemporalDurationFromInternal(internalDuration, roundedLargestUnit).
12991281 // TemporalDurationFromInternal calls CreateTemporalDuration which calls IsValidDuration.
13001282 // When days+time together exceed 2^53 seconds after decomposition, IsValidDuration fails → RangeError.
1301- auto roundedDurationResult = temporalDurationFromInternal (internalDuration, roundedLargestUnit);
1283+ auto roundedDurationResult = TemporalCore:: temporalDurationFromInternal (internalDuration, roundedLargestUnit);
13021284 if (!roundedDurationResult) [[unlikely]] {
13031285 throwTemporalError (globalObject, scope, roundedDurationResult.error ());
13041286 return { };
0 commit comments