Skip to content

Commit 769c135

Browse files
Merge pull request jazzband#113 from glitchedmob/bug/calendar-selecting-wrong-date
Change order that month and date are set
2 parents fca1bdd + 8d3b525 commit 769c135

2 files changed

Lines changed: 5 additions & 18 deletions

File tree

recurrence/static/recurrence/js/recurrence-widget.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,7 @@ recurrence.widget.Calendar.prototype = {
238238
month != this.date.getMonth() ||
239239
day != this.date.getDate()) {
240240

241-
this.date.setFullYear(year);
242-
this.date.setMonth(month);
243-
this.date.setDate(day);
241+
this.date.setTime(new Date(year, month, day).getTime());
244242

245243
recurrence.array.foreach(
246244
this.elements.month_grid.cells, function(cell) {
@@ -405,9 +403,8 @@ recurrence.widget.DateSelector.prototype = {
405403

406404
if (!this.date)
407405
this.date = recurrence.widget.date_today();
408-
this.date.setFullYear(year);
409-
this.date.setMonth(month);
410-
this.date.setDate(day);
406+
407+
this.date.setTime(new Date(year, month, day).getTime());
411408

412409
this.elements.date_field.value = datestring;
413410

recurrence/static/recurrence/js/recurrence.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -679,19 +679,9 @@ recurrence.deserialize = function(text) {
679679
}
680680
var dt = new Date();
681681
if (text.indexOf('Z') > 0) {
682-
dt.setUTCFullYear(year);
683-
dt.setUTCMonth(month - 1);
684-
dt.setUTCDate(day);
685-
dt.setUTCHours(hour);
686-
dt.setUTCMinutes(minute);
687-
dt.setUTCSeconds(second);
682+
dt.setTime(Date.UTC(year, month - 1, day, hour, minute, second) / 1);
688683
} else {
689-
dt.setFullYear(year);
690-
dt.setMonth(month - 1);
691-
dt.setDate(day);
692-
dt.setHours(hour);
693-
dt.setMinutes(minute);
694-
dt.setSeconds(second);
684+
dt.setTime(new Date(year, month - 1, day, hour, minute, second).getTime());
695685
}
696686
return dt;
697687
};

0 commit comments

Comments
 (0)