views:

19

answers:

1

Hey,

is it a bug in jQuery UI? When I call .datepicker('setDate', date); and date is a date-object with time, datepicker set the time of date to 0:00?

And if I clone the variable..

var datewithtime = new Date();
var lTmpDate = datewithtime;
$('#Modal_KalendarTermin #DP_DatumVon').datepicker("setDate", lTmpDate);

.. datewithtime is just the same (without time - only date with time = 0:00).

I found a third parameter "noChange" in the jquery-ui.js -> serach for "_setDate: function". For what?

Excerpt from jquery-ui.js

/* Set the date(s) directly. */
_setDate: function(inst, date, noChange) {
    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();
    if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange)
        this._notifyChange(inst);
    this._adjustInstDate(inst);
    if (inst.input) {
        inst.input.val(clear ? '' : this._formatDate(inst));
    }
},

Thanks for your answers and sorry for my bad english!

A: 

The jQuery UI datepicker only deals with dates. As you can see from the code you've linked to, the date being passed to setDate is only used to set the values of currentDay, currentMonth and currentYear. All other date info will be dropped, by design.

The noChange parameter is a flag, probably only used internally, to determine whether or not to call notifyChange when the values are changed.

David Hedlund