Permalink
Browse files

Calendar bug fixes

  • Loading branch information...
allenrabinovich committed Feb 29, 2012
1 parent 829f44d commit ecb0e3c0ca1489bc78b763cdfb6163c8c1043e2e
@@ -817,7 +817,12 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* set to noon.
*/
_normalizeDate : function (date) {
- return new Date(date.getFullYear(), date.getMonth(), 1, 12, 0, 0, 0);
+ if (date != null) {
+ return new Date(date.getFullYear(), date.getMonth(), 1, 12, 0, 0, 0);
+ }
+ else {
+ return null;
+ }
},
@@ -1574,6 +1579,9 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
if (ydate.areEqual(newDate, this.get('date'))) {
return this.get('date');
}
+ else {
+ return newDate;
+ }
}
},

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -817,7 +817,12 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* set to noon.
*/
_normalizeDate : function (date) {
- return new Date(date.getFullYear(), date.getMonth(), 1, 12, 0, 0, 0);
+ if (date != null) {
+ return new Date(date.getFullYear(), date.getMonth(), 1, 12, 0, 0, 0);
+ }
+ else {
+ return null;
+ }
},
@@ -1574,6 +1579,9 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
if (ydate.areEqual(newDate, this.get('date'))) {
return this.get('date');
}
+ else {
+ return newDate;
+ }
}
},
@@ -433,10 +433,9 @@ Y.Calendar = Y.extend(Calendar, Y.CalendarBase, {
setter: function (val) {
var newDate = this._normalizeDate(val),
- newTopDate = ydate.addMonths(newDate, this._paneNumber - 1),
- minDate = this.get("minimumDate"),
- maxDate = this.get("maximumDate");
-
+ newTopDate = ydate.addMonths(newDate, this._paneNumber - 1);
+ var minDate = this.get("minimumDate");
+ var maxDate = this.get("maximumDate");
if ((minDate == null || ydate.isGreaterOrEqual(newDate, minDate)) &&
(maxDate == null || ydate.isGreaterOrEqual(maxDate, newTopDate))) {
return newDate;
@@ -500,7 +499,7 @@ Y.Calendar = Y.extend(Calendar, Y.CalendarBase, {
return newMaxDate;
}
else {
- return this._normalizeDate(val);
+ return val;
}
}
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -433,10 +433,9 @@ Y.Calendar = Y.extend(Calendar, Y.CalendarBase, {
setter: function (val) {
var newDate = this._normalizeDate(val),
- newTopDate = ydate.addMonths(newDate, this._paneNumber - 1),
- minDate = this.get("minimumDate"),
- maxDate = this.get("maximumDate");
-
+ newTopDate = ydate.addMonths(newDate, this._paneNumber - 1);
+ var minDate = this.get("minimumDate");
+ var maxDate = this.get("maximumDate");
if ((minDate == null || ydate.isGreaterOrEqual(newDate, minDate)) &&
(maxDate == null || ydate.isGreaterOrEqual(maxDate, newTopDate))) {
return newDate;
@@ -500,7 +499,7 @@ Y.Calendar = Y.extend(Calendar, Y.CalendarBase, {
return newMaxDate;
}
else {
- return this._normalizeDate(val);
+ return val;
}
}
}
@@ -815,7 +815,12 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* set to noon.
*/
_normalizeDate : function (date) {
- return new Date(date.getFullYear(), date.getMonth(), 1, 12, 0, 0, 0);
+ if (date != null) {
+ return new Date(date.getFullYear(), date.getMonth(), 1, 12, 0, 0, 0);
+ }
+ else {
+ return null;
+ }
},
@@ -1572,6 +1577,9 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
if (ydate.areEqual(newDate, this.get('date'))) {
return this.get('date');
}
+ else {
+ return newDate;
+ }
}
},
@@ -431,10 +431,9 @@ Y.Calendar = Y.extend(Calendar, Y.CalendarBase, {
setter: function (val) {
var newDate = this._normalizeDate(val),
- newTopDate = ydate.addMonths(newDate, this._paneNumber - 1),
- minDate = this.get("minimumDate"),
- maxDate = this.get("maximumDate");
-
+ newTopDate = ydate.addMonths(newDate, this._paneNumber - 1);
+ var minDate = this.get("minimumDate");
+ var maxDate = this.get("maximumDate");
if ((minDate == null || ydate.isGreaterOrEqual(newDate, minDate)) &&
(maxDate == null || ydate.isGreaterOrEqual(maxDate, newTopDate))) {
return newDate;
@@ -498,7 +497,7 @@ Y.Calendar = Y.extend(Calendar, Y.CalendarBase, {
return newMaxDate;
}
else {
- return this._normalizeDate(val);
+ return val;
}
}
}
@@ -47,8 +47,8 @@ <h1>Calendar Tests</h1>
},
tearDown : function () {
- delete this.firstcalendar;
- delete this.secondcalendar;
+ delete this.firstcalendar;
+ delete this.secondcalendar;
Y.one('#firstcontainer').remove();
Y.one('#secondcontainer').remove();
},
@@ -110,7 +110,6 @@ <h1>Calendar Tests</h1>
Y.Assert.areEqual("7", Y.one("#firstcontainer").one(".calendar_col8.yui3-calendar-nextmonth-day").getContent());
},
-
testTwoCalendars : function () {
var cfg1 = {
contentBox: "#firstcontainer",
@@ -150,8 +149,7 @@ <h1>Calendar Tests</h1>
var calendarid = this.firstcalendar._calendarId;
Y.one("#" + calendarid + "_pane_0_6_15").simulate("click");
- var currentDate = this.firstcalendar.get("selectedDates")[0];
-
+ var currentDate = this.firstcalendar.get("selectedDates")[0];
Y.Assert.areEqual(currentDate.getFullYear(), 2011);
Y.Assert.areEqual(currentDate.getMonth(), 11);
Y.Assert.areEqual(currentDate.getDate(), 15);
@@ -161,21 +159,20 @@ <h1>Calendar Tests</h1>
Y.one("#" + calendarid + "_pane_0_8_31").simulate("click");
currentDate = this.firstcalendar.get("selectedDates")[0];
-
Y.Assert.areEqual(currentDate.getFullYear(), 2011);
Y.Assert.areEqual(currentDate.getMonth(), 11);
Y.Assert.areEqual(currentDate.getDate(), 31);
-
+
// Click to advance the month
- Y.one(".yui3-calendarnav-nextmonth").simulate("click");
+ Y.one(".yui3-calendarnav-nextmonth").simulate("click");
// Click on a date in the new month
Y.one("#" + calendarid + "_pane_0_8_17").simulate("click");
- currentDate = this.firstcalendar.get("selectedDates")[0];
-
+ currentDate = this.firstcalendar.get("selectedDates")[0];
Y.Assert.areEqual(currentDate.getFullYear(), 2012);
Y.Assert.areEqual(currentDate.getMonth(), 0);
Y.Assert.areEqual(currentDate.getDate(), 17);
+
},
testMultiplePanes : function () {

0 comments on commit ecb0e3c

Please sign in to comment.