MCPcopy
hub / github.com/date-fns/date-fns / differenceInHours

Function differenceInHours

pkgs/core/src/differenceInHours/index.ts:34–46  ·  view source on GitHub ↗
(
  laterDate: DateArg<Date> & {},
  earlierDate: DateArg<Date> & {},
  options?: DifferenceInHoursOptions,
)

Source from the content-addressed store, hash-verified

32 * //=> 12
33 */
34export function differenceInHours(
35 laterDate: DateArg<Date> & {},
36 earlierDate: DateArg<Date> & {},
37 options?: DifferenceInHoursOptions,
38): number {
39 const [laterDate_, earlierDate_] = normalizeDates(
40 options?.in,
41 laterDate,
42 earlierDate,
43 );
44 const diff = (+laterDate_ - +earlierDate_) / millisecondsInHour;
45 return getRoundingMethod(options?.roundingMethod)(diff);
46}

Callers 4

intervalToDurationFunction · 0.90
intlFormatDistanceFunction · 0.90
test.tsFile · 0.90
_testFunction · 0.90

Calls 2

normalizeDatesFunction · 0.90
getRoundingMethodFunction · 0.90

Tested by

no test coverage detected