Permalink
Browse files

MDL-42587: calendar: Fix regression that stops dates autocorrecting

  • Loading branch information...
1 parent 68291f2 commit eed17976dc9547fcdb8c1ef1115b1a85fb8dace6 @aolley aolley committed Oct 29, 2013
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/form/yui/dateselector/dateselector.js
@@ -137,10 +137,16 @@ YUI.add('moodle-form-dateselector', function(Y) {
var year = parseInt(this.yearselect.get('value'));
var month = parseInt(this.monthselect.get('value')) - 1;
var day = parseInt(this.dayselect.get('value'));
- M.form.dateselector.calendar.select(new Date(year, month, day));
+ var date = new Date(year, month, day);
+ M.form.dateselector.calendar.select(date);
M.form.dateselector.calendar.setMonth(month);
M.form.dateselector.calendar.setYear(year);
M.form.dateselector.calendar.render();
+ if (date.getDate() != day) {
+ // Must've selected the 29 to 31st of a month that doesn't have such dates.
+ this.dayselect.set('value', date.getDate());
+ this.monthselect.set('value', date.getMonth() + 1);
+ }
},
set_selects_from_date : function(eventtype, args) {
var date = args[0][0];

0 comments on commit eed1797

Please sign in to comment.