aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.datepicker.js
diff options
context:
space:
mode:
authorpheiberg <peter@heiberg.se>2010-11-21 22:06:23 +0100
committerScott González <scott.gonzalez@gmail.com>2010-11-22 08:29:29 -0500
commitd69f2ecb1273f382d83b13c349a8c76b17bee2a6 (patch)
tree21aa2006d1f5a9f38e38d77edd39860898b130c3 /ui/jquery.ui.datepicker.js
parent3361e8fe9d94792c399654312d0ee2cf2c8cfe73 (diff)
downloadjquery-ui-d69f2ecb1273f382d83b13c349a8c76b17bee2a6.tar.gz
jquery-ui-d69f2ecb1273f382d83b13c349a8c76b17bee2a6.zip
Datepicker: changed setDate not to modify the passed date argument. Fixes #6671 - setDate manipulates its argument
Diffstat (limited to 'ui/jquery.ui.datepicker.js')
-rw-r--r--ui/jquery.ui.datepicker.js32
1 files changed, 16 insertions, 16 deletions
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js
index 961e1780d..739db1007 100644
--- a/ui/jquery.ui.datepicker.js
+++ b/ui/jquery.ui.datepicker.js
@@ -1315,16 +1315,16 @@ $.extend(Datepicker.prototype, {
}
return new Date(year, month, day);
};
- date = (date == null ? defaultDate : (typeof date == 'string' ? offsetString(date) :
- (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : date)));
- date = (date && date.toString() == 'Invalid Date' ? defaultDate : date);
- if (date) {
- date.setHours(0);
- date.setMinutes(0);
- date.setSeconds(0);
- date.setMilliseconds(0);
+ var newDate = (date == null ? defaultDate : (typeof date == 'string' ? offsetString(date) :
+ (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
+ newDate = (newDate && newDate.toString() == 'Invalid Date' ? defaultDate : newDate);
+ if (newDate) {
+ newDate.setHours(0);
+ newDate.setMinutes(0);
+ newDate.setSeconds(0);
+ newDate.setMilliseconds(0);
}
- return this._daylightSavingAdjust(date);
+ return this._daylightSavingAdjust(newDate);
},
/* Handle switch to/from daylight saving.
@@ -1344,10 +1344,10 @@ $.extend(Datepicker.prototype, {
var clear = !(date);
var origMonth = inst.selectedMonth;
var origYear = inst.selectedYear;
- date = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
- inst.selectedDay = inst.currentDay = date.getDate();
- inst.drawMonth = inst.selectedMonth = inst.currentMonth = date.getMonth();
- inst.drawYear = inst.selectedYear = inst.currentYear = date.getFullYear();
+ var newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
+ inst.selectedDay = inst.currentDay = newDate.getDate();
+ inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
+ inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange)
this._notifyChange(inst);
this._adjustInstDate(inst);
@@ -1625,9 +1625,9 @@ $.extend(Datepicker.prototype, {
_restrictMinMax: function(inst, date) {
var minDate = this._getMinMaxDate(inst, 'min');
var maxDate = this._getMinMaxDate(inst, 'max');
- date = (minDate && date < minDate ? minDate : date);
- date = (maxDate && date > maxDate ? maxDate : date);
- return date;
+ var newDate = (minDate && date < minDate ? minDate : date);
+ newDate = (maxDate && newDate > maxDate ? maxDate : newDate);
+ return newDate;
},
/* Notify change of month/year. */