Opened 13 years ago
Closed 13 years ago
#4514 closed bug (fixed)
IE7/8 dateFormat option messing up default year
Reported by: | quasipickle | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.8 |
Component: | ui.datepicker | Version: | 1.7.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
In IE7/8, when opening a datepicker in dialog mode, and the defaultDate option is set as a Date object, the year is read incorrectly if the dateFormat option is set.
Test page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <script type = "text/javascript" src = "http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script> <script type = "text/javascript" src = "ui.core.js"></script> <script type = "text/javascript" src = "ui.datepicker.js"></script> <script type = "text/javascript"> $(document).ready(function(){ var oDate = new Date(); $("#test").datepicker( 'dialog', oDate, function(dateText,datePicker){ $("#test").val(dateText); }, { defaultDate:oDate, dateFormat:'D M dd yy' } ); }); </script> </head> <body> <input id = "test" type = "text" /> </body> </html>
This code, when run in Firefox, will produce a datepicker dialog with 2009 as the current year. In IE, the current year will be 2016. I believe this stems from the fact that the Date object, when output as a string, appears different in IE & Firefox.
In Mozilla: Fri May 04 2009 16:50:05 GMT-0600 (MDT)
In IE: Fri May 4 16:50:05 MDT 2009
I believe the problem lies in _parseDate() & stems from the fact it tries to determine the date by pulling the date-as-a-string apart, rather than using the functions built into the Date object. However, this is my first time looking at the datepicker code, so I may be way off base.
Change History (4)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
Milestone: | TBD → 1.7.2 |
---|
comment:3 Changed 13 years ago by
Milestone: | 1.7.2 → 1.8 |
---|
comment:4 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
The dialog command expected a string version of the date and so didn't know what to do with a Date object. This has been updated to accept either. Fixed in r2696.
I think if toUTCString() is used rather than toString(), that should fix it.