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

Function compareAsc

pkgs/core/src/compareAsc/index.ts:36–47  ·  view source on GitHub ↗
(
  dateLeft: DateArg<Date> & {},
  dateRight: DateArg<Date> & {},
)

Source from the content-addressed store, hash-verified

34 * // ]
35 */
36export function compareAsc(
37 dateLeft: DateArg<Date> & {},
38 dateRight: DateArg<Date> & {},
39): number {
40 const diff = +toDate(dateLeft) - +toDate(dateRight);
41
42 if (diff < 0) return -1;
43 else if (diff > 0) return 1;
44
45 // Return 0 if diff is 0; return NaN if diff is NaN
46 return diff;
47}

Callers 6

formatDistanceFunction · 0.90
differenceInISOWeekYearsFunction · 0.90
test.tsFile · 0.90
formatDistanceStrictFunction · 0.90
differenceInMonthsFunction · 0.90
differenceInYearsFunction · 0.90

Calls 1

toDateFunction · 0.90

Tested by

no test coverage detected