Skip to content

Commit

Permalink
Ensure that pressing pgdwn or pgup only moves to the next or previous…
Browse files Browse the repository at this point in the history
… month, even if it has less days (in which case go to last day of the month if necessary)
  • Loading branch information
jonleighton committed Mar 19, 2009
1 parent d1b3d56 commit 89fb9c3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion jquery.date_input.js
Expand Up @@ -195,7 +195,12 @@ DateInput.prototype = {
},

moveDateMonthBy: function(amount) {
this.selectDate(new Date(this.selectedDate.setMonth(this.currentMonth.getMonth() + amount)));
var newDate = new Date(this.selectedDate.getFullYear(), this.selectedDate.getMonth() + amount, this.selectedDate.getDate());
if (newDate.getMonth() == this.selectedDate.getMonth() + amount + 1) {
// We have moved too far. For instance 31st March + 1 month = 1st May, not 30th April
newDate.setDate(0);
};
this.selectDate(newDate);
},

prevMonth: function() {
Expand Down

0 comments on commit 89fb9c3

Please sign in to comment.