Opened 6 years ago

Closed 6 years ago

#16913 closed defect (wontfix)

TimeTextBox loses/removes milliseconds

Reported by: barbossusus Owned by: barbossusus
Priority: undecided Milestone: tbd
Component: Dijit - Form Version: 1.8.3
Keywords: Cc:
Blocked By: Blocking:

Description

_setValueAttr in DateTimeTextBox? loses the milliseconds when resets the "value" to a new date. Please see screenshots.

Date Constructors:

1)new Date() current date and time

2)new Date(milliseconds) milliseconds since 1970/01/01

3)new Date(dateString)

4)new Date(year, month, day, hours, minutes, seconds, milliseconds)

The cause seems to be the parameter of the constructor that is cast to String, case 3).

Suggestion:

value = new this.dateClassObj(value);

should become something like:

value = new this.dateClassObj(value.getTime()); (case 2))

Attachments (3)

public_milliseconds_missing.png (19.4 KB) - added by barbossusus 6 years ago.
public_timeTextBox_setValue_after.png (77.8 KB) - added by barbossusus 6 years ago.
public_timeTextBox_setValue_before.png (78.9 KB) - added by barbossusus 6 years ago.

Download all attachments as: .zip

Change History (7)

Changed 6 years ago by barbossusus

Changed 6 years ago by barbossusus

Changed 6 years ago by barbossusus

comment:1 Changed 6 years ago by bill

Owner: changed from Douglas Hays to barbossusus
Status: newpending

I don't get it, why do you care about milliseconds? The drop down of a TimeTextBox never shows seconds, let alone milliseconds. Perhaps users are able to type milliseconds into the TimeTextBox's <input>, but are you actually expecting them to?

PS: Need to be careful not to break support for funky calendars in dojox/date, like buddhist, hebrew, etc. Not sure if they have a getTime() method on their custom Date class.

Last edited 6 years ago by bill (previous) (diff)

comment:2 Changed 6 years ago by barbossusus

Status: pendingnew

Some Dojo users want to be able to specify milliseconds, or just don't want to "lose" information.

My suggestion might not be the best, so please feel free to change it.

comment:3 Changed 6 years ago by barbossusus

Also, could you please change the owner of this ticket.

comment:4 Changed 6 years ago by bill

Resolution: wontfix
Status: newclosed

I'm sure you can get what you want by just defining your own dateClassObj where new dateClassObj(value) copies the milliseconds.

Your suggestion to change the dijit code won't work because:

1) dateClass implementations in dojox/date, like buddhist and hebrew, don't have a getTime() method. Custom user implementations may also not have such a method. In other words the change would break backwards compatibility.

2) TimeTextBox and DateTextBox don't deal with timezones. I.E. the value of each widget is either a date (like 12/25/1980) or a time (like 12:30PM), but without a timezone specification, and thus using value.getTime(), which returns the number of milliseconds since Jan 1, 1970 UTC seems scary.

I'm also underwhelmed by the justification that we need this because "some Dojo users want to be able to specify milliseconds". I've never heard of this before and can't imagine why someone would need that.

So, given all of that, I'm going to close this as wontfix. Please just define your own custom dateClassObj, or monkey-patch _setValueAttr() to do what you want.

Note: See TracTickets for help on using tickets.