Search and Top Navigation
#4514 closed bug (fixed)
Opened May 04, 2009 11:00PM UTC
Closed June 11, 2009 10:28AM UTC
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.
Attachments (0)
Change History (4)
Changed May 05, 2009 09:59PM UTC by comment:1
Changed May 07, 2009 10:04AM UTC by comment:2
| milestone: | TBD → 1.7.2 |
|---|
Changed May 07, 2009 01:29PM UTC by comment:3
| milestone: | 1.7.2 → 1.8 |
|---|
Changed June 11, 2009 10:28AM UTC by comment:4
| 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.