MCPcopy
hub / github.com/youzan/vant-weapp / compareMonth

Function compareMonth

packages/calendar/utils.ts:10–29  ·  view source on GitHub ↗
(date1: Date | number, date2: Date | number)

Source from the content-addressed store, hash-verified

8}
9
10export function compareMonth(date1: Date | number, date2: Date | number) {
11 if (!(date1 instanceof Date)) {
12 date1 = new Date(date1);
13 }
14
15 if (!(date2 instanceof Date)) {
16 date2 = new Date(date2);
17 }
18
19 const year1 = date1.getFullYear();
20 const year2 = date2.getFullYear();
21 const month1 = date1.getMonth();
22 const month2 = date2.getMonth();
23
24 if (year1 === year2) {
25 return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
26 }
27
28 return year1 > year2 ? 1 : -1;
29}
30
31export function compareDay(day1: Date | number, day2: Date | number) {
32 if (!(day1 instanceof Date)) {

Callers 3

scrollIntoViewFunction · 0.90
compareDayFunction · 0.70
getMonthsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected