Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
DateFormat not working between v4.4.1 and v4.5.2. 'Oct ' causes undefined error
17/10/2013
15:14
Avatar
huntygowk
New Member
Members
Forum Posts: 1
Member Since:
16/10/2013
sp_UserOfflineSmall Offline

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

07/11/2013
18:50
Avatar
MetalJim
New Member
Members
Forum Posts: 1
Member Since:
07/11/2013
sp_UserOfflineSmall Offline

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.

10/11/2013
13:14
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information