-
18 Oct 2012 7:21 AM #1
[4.1.2] DateFormat (ISO) does not parse correctly?
[4.1.2] DateFormat (ISO) does not parse correctly?
Hi,
I'm just going into some trouble after we'd deployed/tested the application (with Ext JS 4) on a server not in the same time zone than the clients.
Originally, the date/timestamps are served in the ISO format with timezone:
Since Ext JS 3, we've used the model type "date" + dateFormat "c". If I'm correct this dateFormat wont be supported??PHP Code:// Property of record serverside
datetime : "2012-10-18T16:17:51.299+0200"
Removing the dateFormat (only type "date") works in Chrome/Firefox perfectly (because of internal JS' Date usage), but not in IE (NaN/empty grids).
Because of this issues, I've revisited the doc.. and there are some examples.
I changed the timezone of my VM to Hawaii and use a my-local timezone (Germany).
Using the library with a example string right of the documentation:
Ext.Date.parse("1997-05-16T19:23:30.12345+02:00", "c").toString()
should not be
Fri May 16 1997 19:23:30 GMT-1000 (Hawaii Normalzeit)
but should be
Fri May 16 1997 07:23:30 GMT-1000 (Hawaii Normalzeit).
In Chrome (native)
new Date("1997-05-16T19:23:30.12345+02:00")
is okay. In IE, this is NaN.
edit: Anyway, I've open a ticket.
You break down the whole issue with following one-liner:
Ext.Date.parse("2012-10-18T16:17:51.299+0000", "c")
This date should be the 18th Oct 2012, 16h17m51s (UTC) because timezone 0.
In my case, the local timezone is +0200. So, when using the line above in Ext JS 4.1.1
Thu Oct 18 2012 16:17:51 GMT+0200 (CEST)
But in Ext JS 4.1.2
Thu Oct 18 2012 18:17:51 GMT+0200 (CEST)
I tried it again, the same expression with the timezone Hawaii set up in the operating system.
In Ext JS 4.1.1
Thu Oct 18 2012 06:17:51 GMT-1000 (Hawaii Normalzeit)
But in Ext JS 4.1.2
Thu Oct 18 2012 16:17:51 GMT-1000 (Hawaii Normalzeit)
-
18 Oct 2012 5:28 PM #2
If I run:
Ext 3
Ext 4Code:var s = Date.parseDate('2012-10-18T16:17:51.299+0000', 'c'); console.log(s);
Tried against (with Chrome):Code:var s = Ext.Date.parse('2012-10-18T16:17:51.299+0000', 'c'); console.log(s);
3.4.0
4.0.2a
4.1.1
4.1.2
It all gives me the same result :
Perhaps something else is going on, because this hasn't changed in a while.Code:Fri Oct 19 2012 03:17:51 GMT+1100 (AUS Eastern Daylight Time)
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
18 Oct 2012 9:30 PM #3
I'am replaying your stuff again on Chrome22Firefox14, WinXP, TZ+11.
The testcase is very simple..PHP Code:console.info( Ext.Date.parse('2012-10-18T16:17:51.299+0000', 'c') )
Thu Oct 18 2012 16:17:51 GMT+1100 (Wladiwostok Normalzeit)
console.info (Ext.getVersion().toString() )
4.1.2.1
PHP Code:<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title>Demo</title>
<script src="../libs/ext-4.1.2a/ext-all-debug-w-comments.js"></script>
<link rel="stylesheet" href="../libs/ext-4.1.2a/resources/css/ext-all.css" type="text/css" media="screen" title="no title" charset="utf-8">
</head>
<body>
</body>
</body></html>
-
19 Oct 2012 12:24 AM #4
Got it. Two typos in your code.
In your Ext.Date.Parser for dateFormat "c", there are two if statements: One with "if (W)" and one with if (O). Both of them are wrong.
"if (W)" is actually completely unused (W will be never written).
"if (O)" should be "if (o)".
-
19 Oct 2012 1:14 AM #5
Could you elaborate a bit please?
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
19 Oct 2012 3:20 AM #6
Left 4.1.2a -- right 4.1.2a +Patch.
You will find this in Date.js at line 235.
The same lines are present in 4.1.1, but with a small "o".
The only one step where the timezone will be applied is in these lines
The red O was never be written, but o.Code:// favor UTC offset over GMT offset "if(zz != null){", // reset to UTC, then add offset "v = me.add(v, me.SECOND, -v.getTimezoneOffset() * 60 - zz);", "}else if(O){", // reset to GMT, then add offset "v = me.add(v, me.MINUTE, -v.getTimezoneOffset() + (sn == '+'? -1 : 1) * (hr * 60 + mn));", "}",
Bildschirmfoto 2012-10-19 um 13.11.34.jpg
edit: My local Git diff
Code:diff --git a/src/main/webapp/resources/ext-4.1.2/src/core/src/lang/Date.js b/src/main/webapp/resources/ext-4.1.2/src/core/src/lang/Date.js index 586e9c6..6c4d4cb 100755 --- a/src/main/webapp/resources/ext-4.1.2/src/core/src/lang/Date.js +++ b/src/main/webapp/resources/ext-4.1.2/src/core/src/lang/Date.js @@ -232,7 +232,7 @@ Ext.Date = new function() { "if(zz != null){", // reset to UTC, then add offset "v = me.add(v, me.SECOND, -v.getTimezoneOffset() * 60 - zz);", - "}else if(O){", + "}else if(o){", // reset to GMT, then add offset "v = me.add(v, me.MINUTE, -v.getTimezoneOffset() + (sn == '+'? -1 : 1) * (hr * 60 + mn));", "}",
-
21 Oct 2012 2:56 PM #7
Ok, I'm with you. I got a little confused because this one is already fixed, the current source is the same as what you've got there. Will be part of the next release.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
Success! Looks like we've fixed this one. According to our records the fix was applied for
a bug in our system
in
a recent build.


Reply With Quote