MCPcopy
hub / github.com/logamee/lin-ui / compareMonth

Function compareMonth

src/calendar/util.js:24–43  ·  view source on GitHub ↗
(date1, date2)

Source from the content-addressed store, hash-verified

22}
23
24export function compareMonth(date1, date2) {
25 if (!(date1 instanceof Date)) {
26 date1 = getDate(date1);
27 }
28
29 if (!(date2 instanceof Date)) {
30 date2 = getDate(date2);
31 }
32
33 const year1 = date1.getFullYear();
34 const year2 = date2.getFullYear();
35 const month1 = date1.getMonth();
36 const month2 = date2.getMonth();
37
38 if (year1 === year2) {
39 return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
40 }
41
42 return year1 > year2 ? 1 : -1;
43}
44
45export function compareDay(date1, date2) {
46 if (!(date1 instanceof Date)) {

Callers 3

scrollIntoViewFunction · 0.90
compareDayFunction · 0.85
getMonthsFunction · 0.85

Calls 1

getDateFunction · 0.85

Tested by

no test coverage detected