Opened 8 years ago
Closed 8 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)
Change History (7)
Changed 8 years ago by
Attachment: | public_milliseconds_missing.png added |
---|
Changed 8 years ago by
Attachment: | public_timeTextBox_setValue_after.png added |
---|
Changed 8 years ago by
Attachment: | public_timeTextBox_setValue_before.png added |
---|
comment:1 Changed 8 years ago by
Owner: | changed from Douglas Hays to barbossusus |
---|---|
Status: | new → pending |
comment:2 Changed 8 years ago by
Status: | pending → new |
---|
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:4 Changed 8 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
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.
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.