Opened 14 years ago
Closed 14 years ago
#2338 closed defect (fixed)
Getting "Invalid Date" with dojo.date.setIso8601() with Firefox
Reported by: | Adam Peller | Owned by: | Adam Peller |
---|---|---|---|
Priority: | high | Milestone: | 0.9 |
Component: | Date | Version: | 0.4.1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
Reported by Akira Sudoh (IBM)
When calling dojo.date.setIso8601(new Date, "20070116T141500+09") with Firefox, it returns "Invalid Date".
My investigation indicated that dojo.date code does not consider regular expression tokens being "undefined", which happens with Firefox, when there is no string to match to the token. (Internet Explorer sets null string to such tokens)
In this specific case, dojo.date.setIso8601 performs match a string "20070116T141500+09" to a regular expression "Z|(([-+])([0-9]{2})(:?([0-9]{2}))?)$". And it'll be tokenized as:
0: "20070116T141500+09" 1: "+09" 2: "+" 3: "09" 4: undefined 5: undefined
The token in question is the fifth one, which will be used to calculate timezone offset, using Number(). Number(undefined) returns NaN and that causes "Invalid Date".
I've attached sample HTML to reproduce this and the patch.
Attachments (3)
Change History (4)
Changed 14 years ago by
Attachment: | sample.html added |
---|
comment:1 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Test case from Akira