Skip to content

Commit 295ee65

Browse files
committed
Fix previous / next month buttons to be disabled properly
1 parent 091ef4b commit 295ee65

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

jquery.datepick.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,8 @@ $.extend(Datepicker.prototype, {
139139
keystroke: {keyCode: 33, ctrlKey: true}, // Ctrl + Page up
140140
enabled: function(inst) {
141141
var minDate = inst.curMinDate();
142-
return (!minDate || plugin.add(plugin.day(
143-
plugin._applyMonthsOffset(plugin.add(plugin.newDate(inst.drawDate),
144-
1 - inst.options.monthsToJump, 'm'), inst), 1), -1, 'd').
145-
getTime() >= minDate.getTime()); },
142+
var date = plugin.add(plugin.day(plugin._applyMonthsOffset(plugin.add(plugin.newDate(inst.drawDate),1 - inst.options.monthsToJump, 'm'), inst), 1), -1, 'd');
143+
return (!minDate || (date.getFullYear() * 100) + date.getMonth() > (minDate.getFullYear() * 100) + minDate.getMonth()); },
146144
date: function(inst) {
147145
return plugin.day(plugin._applyMonthsOffset(plugin.add(
148146
plugin.newDate(inst.drawDate), -inst.options.monthsToJump, 'm'), inst), 1); },
@@ -153,9 +151,8 @@ $.extend(Datepicker.prototype, {
153151
keystroke: {keyCode: 34}, // Page down
154152
enabled: function(inst) {
155153
var maxDate = inst.get('maxDate');
156-
return (!maxDate || plugin.day(plugin._applyMonthsOffset(plugin.add(
157-
plugin.newDate(inst.drawDate), inst.options.monthsToStep, 'm'), inst), 1).
158-
getTime() <= maxDate.getTime()); },
154+
var date = plugin.day(plugin._applyMonthsOffset(plugin.add(plugin.newDate(inst.drawDate), inst.options.monthsToStep, 'm'), inst), 1);
155+
return (!maxDate || (date.getFullYear() * 100) + date.getMonth() < (maxDate.getFullYear() * 100) + maxDate.getMonth()); },
159156
date: function(inst) {
160157
return plugin.day(plugin._applyMonthsOffset(plugin.add(
161158
plugin.newDate(inst.drawDate), inst.options.monthsToStep, 'm'), inst), 1); },
@@ -1759,7 +1756,8 @@ $.extend(Datepicker.prototype, {
17591756

17601757
months += this._generateMonth(target, inst, drawDate.getFullYear(),
17611758
monthToGenerate, inst.options.renderer, (row == 0 && col == 0));
1762-
plugin.add(drawDate, 1, 'm');
1759+
1760+
plugin.add(drawDate, 1, 'm');
17631761
}
17641762
monthRows += this._prepare(inst.options.renderer.monthRow, inst).replace(/\{months\}/, months);
17651763
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jQuery-Datepick",
3-
"version": "4.2.1",
3+
"version": "4.2.2",
44
"readme": "README.md",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)