Skip to content

Commit

Permalink
some method renames
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Mar 27, 2024
1 parent da37c78 commit fe37479
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 32 deletions.
28 changes: 14 additions & 14 deletions packages/temporal-polyfill/src/internal/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import { isoMonthsInYear } from './isoMath'
import { MarkerToEpochNano, MoveMarker } from './markerSystem'
import {
moveByIsoDays,
moveDateEfficient,
moveDate,
moveDateTime,
moveToDayOfMonth,
moveZonedEpochSlots,
moveZonedEpochs,
} from './move'
import { RoundingMode } from './options'
import { DiffOptions, copyOptions, refineDiffOptions } from './optionsRefine'
Expand Down Expand Up @@ -143,7 +143,7 @@ export function diffZonedDateTimes<C extends IdLike, T extends IdLike>(
const timeZoneOps = getTimeZoneOps(timeZoneSlot)
const calendarOps = getCalendarOps(calendarSlot)

durationFields = diffZonedEpochs(
durationFields = diffZonedEpochsViaCalendar(
calendarOps,
timeZoneOps,
slots0,
Expand All @@ -163,7 +163,7 @@ export function diffZonedDateTimes<C extends IdLike, T extends IdLike>(
// MarkerMoveSystem...
slots0,
extractEpochNano as MarkerToEpochNano,
bindArgs(moveZonedEpochSlots, calendarOps, timeZoneOps) as MoveMarker,
bindArgs(moveZonedEpochs, calendarOps, timeZoneOps) as MoveMarker,
)
}

Expand Down Expand Up @@ -209,7 +209,7 @@ export function diffPlainDateTimes<C extends IdLike>(
} else {
const calendarOps = getCalendarOps(calendarSlot)

durationFields = diffDateTimes(
durationFields = diffDateTimesViaCalendar(
calendarOps,
plainDateTimeSlots0,
plainDateTimeSlots1,
Expand Down Expand Up @@ -352,7 +352,7 @@ function diffDateLike(
// MarkerMoveSystem...
startIsoFields,
isoToEpochNano as MarkerToEpochNano,
bindArgs(moveDateEfficient, calendarOps) as MoveMarker,
bindArgs(moveDate, calendarOps) as MoveMarker,
)
}
}
Expand Down Expand Up @@ -394,10 +394,10 @@ export function diffPlainTimes(
)
}

// Exact Diffing (no rounding): Efficient
// Exact Diffing (no rounding): Attempt Day/Time, fallback to Calendar
// -----------------------------------------------------------------------------

export function diffZonedEpochsEfficient(
export function diffZonedEpochs(
calendarOps: DiffOps,
timeZoneOps: TimeZoneOps,
slots0: ZonedEpochSlots,
Expand All @@ -418,7 +418,7 @@ export function diffZonedEpochsEfficient(
)
}

return diffZonedEpochs(
return diffZonedEpochsViaCalendar(
calendarOps,
timeZoneOps,
slots0,
Expand All @@ -429,7 +429,7 @@ export function diffZonedEpochsEfficient(
)
}

export function diffDateTimesEfficient(
export function diffDateTimes(
calendarOps: DiffOps,
startIsoFields: IsoDateTimeFields,
endIsoFields: IsoDateTimeFields,
Expand All @@ -451,7 +451,7 @@ export function diffDateTimesEfficient(
)
}

return diffDateTimes(
return diffDateTimesViaCalendar(
calendarOps,
startIsoFields,
endIsoFields,
Expand All @@ -461,7 +461,7 @@ export function diffDateTimesEfficient(
)
}

// Exact Diffing (no rounding): Low-Level Work
// Exact Diffing (no rounding): Directly w/ Calendar
// -----------------------------------------------------------------------------

export function zonedEpochRangeToIso(
Expand Down Expand Up @@ -501,7 +501,7 @@ export function zonedEpochRangeToIso(
return [startIsoFields, midIsoFields, timeDiffNano]
}

function diffZonedEpochs(
function diffZonedEpochsViaCalendar(
calendarOps: DiffOps,
timeZoneOps: TimeZoneOps,
slots0: ZonedEpochSlots,
Expand Down Expand Up @@ -532,7 +532,7 @@ function diffZonedEpochs(
return dateTimeDiff
}

function diffDateTimes(
function diffDateTimesViaCalendar(
calendarOps: DiffOps,
startIsoFields: IsoDateTimeFields,
endIsoFields: IsoDateTimeFields,
Expand Down
6 changes: 3 additions & 3 deletions packages/temporal-polyfill/src/internal/diffExtended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { DurationFields } from './durationFields'
import { IsoDateFields } from './isoFields'
import { Marker, MarkerToEpochNano, MoveMarker } from './markerSystem'
import { moveDateTime, moveZonedEpochSlots } from './move'
import { moveDateTime, moveZonedEpochs } from './move'
import {
RoundingMathOptions,
RoundingModeName,
Expand Down Expand Up @@ -53,7 +53,7 @@ function diffZonedLargeUnits(
return diffDateUnits(
extractEpochNano as MarkerToEpochNano,
bindArgs(zonedEpochRangeToIso, timeZoneOps) as MarkersToIsoFields,
bindArgs(moveZonedEpochSlots, calendarOps, timeZoneOps) as MoveMarker,
bindArgs(moveZonedEpochs, calendarOps, timeZoneOps) as MoveMarker,
(f0: IsoDateFields, f1: IsoDateFields) =>
calendarOps.dateUntil(f0, f1, unit),
unit,
Expand Down Expand Up @@ -104,7 +104,7 @@ function diffZonedDayLikeUnits(
return diffDateUnits(
extractEpochNano as MarkerToEpochNano,
bindArgs(zonedEpochRangeToIso, timeZoneOps) as MarkersToIsoFields,
bindArgs(moveZonedEpochSlots, calendarOps, timeZoneOps) as MoveMarker,
bindArgs(moveZonedEpochs, calendarOps, timeZoneOps) as MoveMarker,
diffIsoFields,
unit,
record0,
Expand Down
14 changes: 5 additions & 9 deletions packages/temporal-polyfill/src/internal/markerSystem.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { BigNano } from './bigNano'
import { DiffOps, MoveOps } from './calendarOps'
import { diffDateTimesEfficient, diffZonedEpochsEfficient } from './diff'
import { diffDateTimes, diffZonedEpochs } from './diff'
import { DurationFields } from './durationFields'
import {
IsoDateFields,
IsoDateTimeFields,
isoTimeFieldDefaults,
} from './isoFields'
import { moveDateTime, moveZonedEpochSlots } from './move'
import { moveDateTime, moveZonedEpochs } from './move'
import { DateSlots, EpochAndZoneSlots, ZonedEpochSlots } from './slots'
import { isoToEpochNano } from './timeMath'
import { TimeZoneOps } from './timeZoneOps'
Expand Down Expand Up @@ -72,7 +72,7 @@ export function createMoveMarker(
timeZoneOps: TimeZoneOps | undefined,
): MoveMarker {
if (timeZoneOps) {
return bindArgs(moveZonedEpochSlots, calendarOps, timeZoneOps) as Callable
return bindArgs(moveZonedEpochs, calendarOps, timeZoneOps) as Callable
}
return bindArgs(moveDateTime, calendarOps) as Callable
}
Expand All @@ -82,13 +82,9 @@ export function createDiffMarkers(
timeZoneOps: TimeZoneOps | undefined,
): DiffMarkers {
if (timeZoneOps) {
return bindArgs(
diffZonedEpochsEfficient,
calendarOps,
timeZoneOps,
) as Callable
return bindArgs(diffZonedEpochs, calendarOps, timeZoneOps) as Callable
}
return bindArgs(diffDateTimesEfficient, calendarOps) as Callable
return bindArgs(diffDateTimes, calendarOps) as Callable
}

export function anyMarkerToEpochNano(marker: Marker): BigNano {
Expand Down
12 changes: 6 additions & 6 deletions packages/temporal-polyfill/src/internal/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export function moveZonedDateTime<C, T>(

return {
...zonedDateTimeSlots, // retain timeZone/calendar, order
...moveZonedEpochSlots(
...moveZonedEpochs(
calendarOps,
timeZoneOps,
zonedDateTimeSlots,
Expand Down Expand Up @@ -130,7 +130,7 @@ export function movePlainDate<C>(
): PlainDateSlots<C> {
const { calendar } = plainDateSlots
return createPlainDateSlots(
moveDateEfficient(
moveDate(
getCalendarOps(calendar),
plainDateSlots,
doSubtract ? negateDurationFields(durationSlots) : durationSlots,
Expand Down Expand Up @@ -204,7 +204,7 @@ function moveEpochNano(
/*
timeZoneOps must be derived from zonedEpochSlots.timeZone
*/
export function moveZonedEpochSlots(
export function moveZonedEpochs(
calendarOps: MoveOps,
timeZoneOps: TimeZoneOps,
slots: ZonedEpochSlots,
Expand All @@ -219,7 +219,7 @@ export function moveZonedEpochSlots(
refineOverflowOptions(options) // for validation only
} else {
const isoDateTimeFields = zonedEpochSlotsToIso(slots, timeZoneOps)
const movedIsoDateFields = moveDateEfficient(
const movedIsoDateFields = moveDate(
calendarOps,
isoDateTimeFields,
{
Expand Down Expand Up @@ -256,7 +256,7 @@ export function moveDateTime(
durationFields,
)

const movedIsoDateFields = moveDateEfficient(
const movedIsoDateFields = moveDate(
calendarOps,
isoDateTimeFields, // only date parts will be used
{
Expand All @@ -276,7 +276,7 @@ export function moveDateTime(
/*
Skips calendar if moving days only
*/
export function moveDateEfficient(
export function moveDate(
calendarOps: MoveOps,
isoDateFields: IsoDateFields,
durationFields: DurationFields,
Expand Down

0 comments on commit fe37479

Please sign in to comment.