Opened 14 years ago

Closed 13 years ago

#1298 closed defect (wontfix)

Unexpected TimePicker.setDateTime() behavior

Reported by: [email protected] Owned by: dylan
Priority: high Milestone: 1.0
Component: Widgets Version: 0.3
Keywords: Cc:
Blocked By: Blocking:


Upon upgrading from 0.2.2 to 0.3.1, I ran into some unexpected behavior with the TimePicker?.setDateTime() function. Of course, I am probably not using the widget as intended, but here's what I am seeing...


I am using createWidget() to create the timepicker sub-widget with no parameters (like "time" or "useDefaultTime"). Once the TimePicker?() is created, then I later initialize the time on the TimePicker? with:

timepicker.setDateTime(rfcDate) timepicker.fillInTemplate();

In version 0.2.2 this correctly updated the timepicker widget. In 0.3.1, creating a timepicker with no params will default to selecting the "Any Time" node. The way the widget flags this behavior, is to set

this.selectedTime.anyTime = true;

However, once this value is set to true, the initUI() function will forever skip updating the widget's UI time.

Proposed Fix:

At the start of the fillInTemplate() function, set selectedTime.anyTime = false. A better place for this is in the sub-function called initData():

this.initData = function() {
           // FIXME: doesn't currently validate the time before trying to set it
           // Determine the date/time from stored info, or by default don't
           //  have a set time
           // FIXME: should normalize against whitespace on storedTime... for now
           // just a lame hack
           *this.selectedTime.anyTime = false;*  //<<<<<<<<<<<RIGHT   HERE<<<<<<<
           if(this.storedTime.indexOf("T")!=-1 &&
   this.storedTime.split("T")[1] && this.storedTime!=" " &&
   this.storedTime.split("T")[1]!="any") {
               this.time =
   this.useDefaultMinutes, this.selectedTime.anyTime);
           } else if (this.useDefaultTime) {
               this.time =
   this.useDefaultMinutes, this.selectedTime.anyTime);
           } else {
               this.selectedTime.anyTime = true;
               this.time =
   dojo.widget.TimePicker.util.fromRfcDateTime("", 0, 1);


If you need to work around this problem you can do one of two things: 1) add a the useDefautTime parameter to createWidget():

this.timePicker = dojo.widget.createWidget("timepicker",{useDefaultTime:'true'}, this._timePickerNode,"last");

which add a little bit of unnecessary math overhead, or

2) clear the selected "Any Time" node before calling fillInTemplate():

this.timePicker.setDateTime(rfcDate); this.timePicker.onClearSelectedAnyTime(); this.timePicker.fillInTemplate();

Either way shouldn't be much of a performance difference and will avoid this issue.

Hope this helps someone.


Change History (2)

comment:1 Changed 14 years ago by dylan

Component: GeneralWidgets
Milestone: 0.5
Owner: changed from anonymous to dylan
Status: newassigned

I designed it this way on purpose, but if people agree with you, I can either make this a config option or the default way.

comment:2 Changed 13 years ago by bill

Milestone: 0.91.0
Resolution: wontfix
Status: assignedclosed

We don't have a timepicker at all in dijit... deferring.

Note: See TracTickets for help on using tickets.