<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: errors in parseDate method with 'F', 'M' and 'j' formats</title>
	<link>http://www.trirand.com/blog/?page_id=393/bugs/errors-in-parsedate-method-with-f-m-and-j-formats</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/bugs/errors-in-parsedate-method-with-f-m-and-j-formats/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on errors in parseDate method with 'F', 'M' and 'j' formats</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/errors-in-parsedate-method-with-f-m-and-j-formats#p25882</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/errors-in-parsedate-method-with-f-m-and-j-formats#p25882</guid>
        	        	<description><![CDATA[<p>Sorry Oleg,</p>
<p>You are right. Little busy these days.</p>
<p>Will be fixed.</p>
</p>
<p>Regards</p>
]]></description>
        	        	<pubDate>Tue, 07 Feb 2012 11:44:26 +0200</pubDate>
        </item>
        <item>
        	<title>OlegK on errors in parseDate method with 'F', 'M' and 'j' formats</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/errors-in-parsedate-method-with-f-m-and-j-formats#p25878</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/errors-in-parsedate-method-with-f-m-and-j-formats#p25878</guid>
        	        	<description><![CDATA[<p>Hello Tony,</p>
<p>if one uses <strong>formatoptions: { newformat: &#39;n/j/Y&#39; }</strong>&#160;the format array will be [&#39;n&#39;,&#39;j&#39;, &#39;Y&#39;] so the line</p>
<p><input type='button' class='sfcodeselect' name='sfselectit9979' value='Select Code' data-codeid='sfcode9979' /></p>
<div class='sfcode' id='sfcode9979'>tsp[format[k].toLowerCase()] = parseInt(date[k],10);</div>
<p>will have <strong>format[k]=&#39;n&#39;</strong> and then <strong>&#39;j&#39;</strong>. So the &#160;<strong>tsp.n</strong>&#160;and&#160;<strong>tsp.j</strong>&#160;will be set, but the current code will uses initial <strong>tsp.d</strong> and <strong style="font-weight: bold;">tsp.m</strong>.</p>
<p>If you will debug the searching filtering by date with the <strong>formatoptions: { newformat: &#39;n/j/Y&#39; }</strong>&#160;you will see that the day or the month of the date typed in the search field will be decoded wrong in the current code. The usage of <strong>formatoptions: { newformat: &#39;ShortDate&#39; }</strong>&#160;will produce even the wrond year.</p>
<p>Best regards<br />Oleg&#160;</p>
]]></description>
        	        	<pubDate>Mon, 06 Feb 2012 10:29:12 +0200</pubDate>
        </item>
        <item>
        	<title>tony on errors in parseDate method with 'F', 'M' and 'j' formats</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/errors-in-parsedate-method-with-f-m-and-j-formats#p25877</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/errors-in-parsedate-method-with-f-m-and-j-formats#p25877</guid>
        	        	<description><![CDATA[<p>Hello Oleg,</p>
<p>Not sure what you want to do, but in you code <strong>tsp.n</strong> ans <strong>tsp.j</strong> are always undefined</p>
<p>Regards</p>
]]></description>
        	        	<pubDate>Mon, 06 Feb 2012 09:13:09 +0200</pubDate>
        </item>
        <item>
        	<title>OlegK on errors in parseDate method with 'F', 'M' and 'j' formats</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/errors-in-parsedate-method-with-f-m-and-j-formats#p25872</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/errors-in-parsedate-method-with-f-m-and-j-formats#p25872</guid>
        	        	<description><![CDATA[<p>Hello Tony,</p>
<p>it&#39;s a pity that the bug still not fixed in the jqGrid. The easy way to test the problem would be define jqGrid with local data and the "Search" button in the navigator. The date from the searching dialog will be parsed with respect of <strong>formatoptions.newformat</strong> opetion of the <strong>colModel</strong>. If one would use <strong>formatter: &#39;date&#39;, formatoptions: { newformat: &#39;n/j/Y&#39; }</strong> or <strong>formatter: &#39;date&#39;, formatoptions: { newformat: &#39;ShortDate&#39; }</strong> the date will be wrong parsed currently.</p>
<p>I can extend the bug fix to include support of <strong>&#39;n&#39;</strong> format and the different "name" forms like <strong>&#39;ShortDate&#39;</strong>, <strong>&#39;ISO8601Short&#39;</strong> and so on. My current suggestion to fix the code of <strong>parseDate</strong> is the following</p>
<p><input type='button' class='sfcodeselect' name='sfselectit8584' value='Select Code' data-codeid='sfcode8584' /></p>
<div class='sfcode' id='sfcode8584'>parseDate : function(format, date) {<br />&#160; &#160; var tsp = {m : 1, d : 1, y : 1970, h : 0, i : 0, s : 0, u:0},k,hl,dM, regdate = /[\/:_;.,tTs-]/;<br />&#160; &#160; if(date &#38;&#38; date !== null &#38;&#38; date !== undefined){<br />&#160; &#160; &#160; &#160; date = $.trim(date);<br />&#160; &#160; &#160; &#160; date = date.split(regdate);<br />&#160; &#160; &#160; &#160; <strong>if ($.jgrid.formatter.date.masks[format] !== undefined) {<br />&#160; &#160; &#160; &#160; &#160; &#160; format = $.jgrid.formatter.date.masks[format];<br />&#160; &#160; &#160; &#160; }</strong><br />&#160; &#160; &#160; &#160; format = format.split(regdate);<br />&#160; &#160; &#160; &#160; var dfmt &#160;= $.jgrid.formatter.date.monthNames;<br />&#160; &#160; &#160; &#160; var afmt &#160;= $.jgrid.formatter.date.AmPm;<br />&#160; &#160; &#160; &#160; var h12to24 = function(ampm, h){<br />&#160; &#160; &#160; &#160; &#160; &#160; if (ampm === 0){ if (h === 12) { h = 0;} }<br />&#160; &#160; &#160; &#160; &#160; &#160; else { if (h !== 12) { h += 12; } }&#160;<br />&#160; &#160; &#160; &#160; &#160; &#160; return h;<br />&#160; &#160; &#160; &#160; };<br />&#160; &#160; &#160; &#160; for(k=0,hl=format.length;k&#60;hl;k++){<br />&#160; &#160; &#160; &#160; &#160; &#160; if(format[k] == &#39;M&#39;) {<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; dM = $.inArray(date[k],dfmt);<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; if(dM !== -1 &#38;&#38; dM &#60; 12){<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; date[k] = dM+1;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <strong>tsp.m = date[k];</strong><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; }<br />&#160; &#160; &#160; &#160; &#160; &#160; }<br />&#160; &#160; &#160; &#160; &#160; &#160; if(format[k] == &#39;F&#39;) {<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; dM = $.inArray(date[k],dfmt);<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; if(dM !== -1 &#38;&#38; dM &#62; 11){<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; date[k] = dM+1-12;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <strong>tsp.m = date[k];</strong><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; }<br />&#160; &#160; &#160; &#160; &#160; &#160; }<br />&#160; &#160; &#160; &#160; &#160; &#160; if(format[k] == &#39;a&#39;) {<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; dM = $.inArray(date[k],afmt);<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; if(dM !== -1 &#38;&#38; dM &#60; 2 &#38;&#38; date[k] == afmt[dM]){<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; date[k] = dM;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; tsp.h = h12to24(date[k], tsp.h);<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; }<br />&#160; &#160; &#160; &#160; &#160; &#160; }<br />&#160; &#160; &#160; &#160; &#160; &#160; if(format[k] == &#39;A&#39;) {<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; dM = $.inArray(date[k],afmt);<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; if(dM !== -1 &#38;&#38; dM &#62; 1 &#38;&#38; date[k] == afmt[dM]){<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; date[k] = dM-2;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; tsp.h = h12to24(date[k], tsp.h);<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; }<br />&#160; &#160; &#160; &#160; &#160; &#160; }<br />&#160; &#160; &#160; &#160; &#160; &#160; if(date[k] !== undefined) {<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; tsp[format[k].toLowerCase()] = parseInt(date[k],10);<br />&#160; &#160; &#160; &#160; &#160; &#160; }<br />&#160; &#160; &#160; &#160; }<br />&#160; &#160; &#160; &#160; tsp.m = parseInt(tsp.m,10)-1;<br />&#160; &#160; &#160; &#160; var ty = tsp.y;<br />&#160; &#160; &#160; &#160; if (ty &#62;= 70 &#38;&#38; ty &#60;= 99) {tsp.y = 1900+tsp.y;}<br />&#160; &#160; &#160; &#160; else if (ty &#62;=0 &#38;&#38; ty &#60;=69) {tsp.y= 2000+tsp.y;}<br />&#160; &#160; &#160; &#160; <strong>if(tsp.n !== undefined) { tsp.m = parseInt(tsp.n,10)-1; }</strong><br />&#160; &#160; &#160; &#160; <strong>if(tsp.j !== undefined) { tsp.d = tsp.j; }</strong><br />&#160; &#160; }<br />&#160; &#160; return new Date(tsp.y, tsp.m, tsp.d, tsp.h, tsp.i, tsp.s, tsp.u);<br />}&#160;</div>
<p>I can add that the <a href="http://php.net/manual/en/function.date.php" target="_blank">&#39;S&#39; format</a>&#160;are still not supported in the <strong>parseDate</strong>. The bold lines in the above code are the lines which I suggest to add to fix the existing bug.</p>
<p>Best regards<br />Oleg</p>
]]></description>
        	        	<pubDate>Sun, 05 Feb 2012 14:29:47 +0200</pubDate>
        </item>
        <item>
        	<title>OlegK on errors in parseDate method with 'F', 'M' and 'j' formats</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/errors-in-parsedate-method-with-f-m-and-j-formats#p25721</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/errors-in-parsedate-method-with-f-m-and-j-formats#p25721</guid>
        	        	<description><![CDATA[<p>Hello Tony,</p>
<p>during writing of the answer I found some small bugs in the <a href="https://github.com/tonytomov/jqGrid/blob/v4.3.1/js/grid.base.js#L84-130" target="_blank">parseDate</a> method with &#39;F&#39;, &#39;M&#39; and &#39;j&#39; formats. To fix the problem one should add additional lines in three places which I marked below fett:</p>
<p><input type='button' class='sfcodeselect' name='sfselectit8636' value='Select Code' data-codeid='sfcode8636' /></p>
<div class='sfcode' id='sfcode8636'>
<pre>...<br />	for(k=0,hl=format.length;k&#60;hl;k++){
		if(format[k] == &#39;M&#39;) {
			dM = $.inArray(date[k],dfmt);
			if(dM !== -1 &#38;&#38; dM &#60; 12){
				date[k] = dM+1;
				<strong>tsp.m = date[k];</strong>
			}
		}
		if(format[k] == &#39;F&#39;) {
			dM = $.inArray(date[k],dfmt);
			if(dM !== -1 &#38;&#38; dM &#62; 11){
				date[k] = dM+1-12;
				<strong>tsp.m = date[k];</strong>
			}
		}
		if(format[k] == &#39;a&#39;) {
			dM = $.inArray(date[k],afmt);
			if(dM !== -1 &#38;&#38; dM k&#60; 2 &#38;&#38; date[k] == afmt[dM]){
				date[k] = dM;
				tsp.h = h12to24(date[k], tsp.h);
			}
		}
		if(format[k] == &#39;A&#39;) {
			dM = $.inArray(date[k],afmt);
			if(dM !== -1 &#38;&#38; dM &#62; 1 &#38;&#38; date[k] == afmt[dM]){
				date[k] = dM-2;
				tsp.h = h12to24(date[k], tsp.h);
			}
		}
		if(date[k] !== undefined) {
			tsp[format[k].toLowerCase()] = parseInt(date[k],10);
		}
	}
	tsp.m = parseInt(tsp.m,10)-1;
	var ty = tsp.y;
	if (ty &#62;= 70 &#38;&#38; ty &#60;= 99) {tsp.y = 1900+tsp.y;}
	else if (ty &#62;=0 &#38;&#38; ty &#60;=69) {tsp.y= 2000+tsp.y;}
	<strong>if(tsp.j !== undefined) { tsp.d = tsp.j; }</strong>
}
return new Date(tsp.y, tsp.m, tsp.d, tsp.h, tsp.i, tsp.s, tsp.u);

</pre>
</div>
<p>One can use&#160;<a href="http://www.ok-soft-gmbh.com/jqGrid/SearchingToolbarWithDatepicker.htm" target="_blank">the demo</a>&#160;to verify that after the modification the filtering work corrct.</p>
<p>Best regards<br />Oleg&#160;</p>
]]></description>
        	        	<pubDate>Wed, 18 Jan 2012 19:39:28 +0200</pubDate>
        </item>
</channel>
</rss>