#13935 closed defect (fixed)
Calendar does not accept ISO date with Safari
Reported by: | Philippe May | Owned by: | bill |
---|---|---|---|
Priority: | high | Milestone: | 1.7 |
Component: | Dijit | Version: | 1.7.0b1 |
Keywords: | Calendar Safari | Cc: | |
Blocked By: | Blocking: |
Description
Setting a proper ISO date value to a calendar widget fails with Safari (5.1, Snow Leopard, Dojo trunk). This bug can be seen on the second calendar of http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/tests/test_Calendar.html where no date is selected (it should be 2008-03-14
).
It seems there's a bug in the native Date function: it accepts a localized date (like 17/09/2011
with French locale).
But new Date('2011-09-09')
returns Invalid Date
.
This also affects dojox calendars.
Attachments (2)
Change History (9)
comment:1 Changed 9 years ago by
comment:2 Changed 9 years ago by
That value should be passed to dojo.date.stamp.fromISOString, not the Date constructor. If a dojox calendar is using the Date constructor this way, it may be a separate bug.
Changed 9 years ago by
Attachment: | MultiSelectCalendar.js.diff added |
---|
Patch for dojox.widget.MultiSelectCalendar?, including a change of the constructor matching dijit.CalendarLite?
comment:3 Changed 9 years ago by
Owner: | set to bill |
---|---|
Status: | new → assigned |
Hi aprilmay,
There's actually a bug in the dijit test file. Calendar / CalendarLite will accept a number or a Date for the set("value", ...) call, but they don't accept a String. (Maybe it should accept a string, but it doesn't, according to it's spec.)
Normally you don't have to worry about using strings since the parser will convert a string like value="2008-03-14" into a Date before the value gets to the Calendar widget. However, the test file, starting with 1.6, is doing
data-dojo-props='dayWidth:"abbr", value:"2008-03-14"'
so the parser is hands-off, doing no conversions. The markup should either be:
data-dojo-props='dayWidth:"abbr", value:dojo.date.stamp.fromISOString("2008-03-14")'
or
data-dojo-props='dayWidth:"abbr"' value="2008-03-14"
I'll update the dijit test file.
As for dojox MultiSelectCalendar, I suspect it's the same issue (an error with the test file), but can you file a separate ticket for that issue? It will be handled by someone else.
comment:4 Changed 9 years ago by
PS: I do think it would be a good enhancement for Calendar to accept a string, so I filed #14139.
comment:5 Changed 9 years ago by
PPS: Oh, there's another problem (does your patch fix this?) where the Calendar's grid isn't updated to reflect the initially specified value, even if it's specified as a Date. I filed that as #14140.
This sounds familiar. IIRC someone hit this problem and had a solution calling either new Date() or new Date(""), either once, or every time prior to initializing a Calendar.
Note that we already have some workaround code for another browser bug, in _DateTimeTextBox.js: