Forum
15:14
16/10/2013
I've app 1 running with jqgrid v4.4.1
Dates are displayed using the following format:
date supplied by json response "Oct 7, 2013 9:44:13 AM"
srcformat:'M d, Y h:i:s A',newformat:'D M j G:i:s'
date displayed on screen: Mon Oct 7 9:44:13
In app 2 which uses jqgrid v4.5.2 I get the following:
date supplied by json response "Oct 7, 2013 9:44:13 AM"
srcformat:'M d, Y h:i:s A',newformat:'D M j G:i:s'
date displayed: undefined undefined NaN NaN:NaN:NaN
If I change the month in the json response to anything except 'Oct' the correct date is displayed.
I can't 'downgrade' app 2 to 4.4.1 as the code that uses v4.5.2 breaks using v4.4.1 of jqgrid.
Upgrading the jqversion in app1 to v4.5.2 causes the same bug described above.
Is this a known bug?
Regards
Huntygowk
18:50
07/11/2013
I just ran into this problem today and came up with a fix for it. I was going to start a new post, but here we go.
The problem has to do with the way those types of dates are parsed. in the parseDate() method there are these 2 lines.
date = String(date).replace(/\\T/g,"T").replace(/\\t/,"T").split(opts.parseRe);
format = format.replace(/\\T/g,"T").replace(/\\t/,"T").split(opts.parseRe);
So what its doing is replacing any "\T" sequences with 'T" and replacing "\t" with just 't', then it splits it with the regular expression.
parseRe : /[Tt\\\/:_;.,\t\s-]/,
The first part of the regular expression defines "T" and "t" as seperators - so any month with a 'T' or 't' in them will be split there. When you debug it, Oct comes in as "Oc" - which is why it fails. What I did to fix it was to change the replace commands with characters that do not appear in any month names.
date = String(date).replace(/\\T/g,"#").replace(/\\t/,"%").split(opts.parseRe);
format = format.replace(/\\T/g,"#").replace(/\\t/,"%").split(opts.parseRe);
Also, I changed the regular expression to include the new replacement characters.
parseRe : /[#%\\\/:_;.,\t\s-]/,
That did the trick for me. Good luck.
13:14
Moderators
30/10/2007
Hello,
Many thanks. Fixed in GitHub.
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
26 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66