equalsDate(inp.datepicker('getDate'), minDate, 'Set date min/max - setDate < min');
inp.datepicker('setDate', date2);
equalsDate(inp.datepicker('getDate'), maxDate, 'Set date min/max - setDate > max');
+ var dateAndTimeToSet = new Date(2008, 3 - 1, 28, 1, 11, 0);
+ var dateAndTimeClone = new Date(2008, 3 - 1, 28, 1, 11, 0);
+ inp.datepicker('setDate', dateAndTimeToSet);
+ equals(dateAndTimeToSet.getTime(), dateAndTimeClone.getTime(), 'Date object passed should not be changed by setDate');
});
test('altField', function() {
}
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.
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);
_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. */