PDA

View Full Version : [CLOSED][3.0.3] ISO 8601 Date format doesn't understand short timezone



grzegorz.borkowski
16 Jan 2010, 2:48 PM
The wikipedia article on ISO 8601 http://en.wikipedia.org/wiki/ISO_8601 claims that time zones can be specified in 4 different ways:
<time>Z
<time>±hh:mm
<time>±hhmm
<time>±hh
From those 4, Ext-JS is able to decode (when you use 'c' date format specifier) only first three. When my service returns date in the short time zone style (±hh), Ext doesn't recognize it.
Here is a test case:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Testcase</title>
<script type="text/javascript" src="../../adapter/ext/ext-base-debug.js"></script>
<script type="text/javascript" src="../../ext-all-debug.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function() {
var date1 = "2010-01-16T19:28+01:00";
var date2 = "2010-01-16T19:28+0100";
var date3 = "2010-01-16T19:28+01";
alert('Parsed date1: "' + date1 + '": ' + Date.parseDate(date1, 'c')
+'\nParsed date2: "' + date2 + '": ' + Date.parseDate(date2, 'c')
+'\nParsed date3: "' + date3 + '": ' + Date.parseDate(date3, 'c'));
})
</script>
</body>
</html>

mystix
16 Jan 2010, 11:35 PM
This is by design.

That list up on wikipedia is not exhaustive
-- the full ISO8601 date spec is much longer than that, unfortunately. :s
(see http://www.pvv.org/~nsaa/8601v2000.pdf -- that's a copy of the 2000 edition of the spec. the latest 2004 edition of the spec costs an arm and a leg to obtain. also see http://www.iso.org/iso/date_and_time_format for a brief summary of the spec).

Since it's impractical to implement detection for all possible IS08601 representations, the current implementation of the Date class's c format specifier is based on W3C's Date and Time Formats recommendation:
http://www.w3.org/TR/NOTE-datetime

where the timezone offset, if specified, must include both hours and minutes.

HTH. :)