Skip to content

Commit 27f1fe4

Browse files
committed
Added isSameMonth() to check if two dates are in the same month.
Added a check in setValue() so that the prev/next links are only hidden, if the min/max dates are in the same month.
1 parent fc1115e commit 27f1fe4

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/dateinput/dateinput.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@
143143
d1.getMonth() == d2.getMonth() &&
144144
d1.getDate() == d2.getDate();
145145
}
146+
147+
function isSameMonth(d1, d2) {
148+
return (d1.getFullYear() === d2.getFullYear() && d1.getMonth() == d2.getMonth());
149+
}
146150

147151
function parseDate(val) {
148152

@@ -585,11 +589,20 @@
585589

586590
// disabled
587591
if (min && date < min) {
588-
a.add(pm).addClass(css.disabled);
592+
if(isSameMonth(date, min)) {
593+
a.addClass(css.disabled);
594+
} else {
595+
a.add(pm).addClass(css.disabled);
596+
}
597+
589598
}
590599

591600
if (max && date > max) {
592-
a.add(nm).addClass(css.disabled);
601+
if(isSameMonth(date, max)) {
602+
a.addClass(css.disabled);
603+
} else {
604+
a.add(nm).addClass(css.disabled);
605+
}
593606
}
594607

595608
a.attr("href", "#" + num).text(num).data("date", date);

0 commit comments

Comments
 (0)