webERP Forum
Calendar Date Picker - Off by One Month? SOLVED - Printable Version

+- webERP Forum (http://www.weberp.org/forum)
+-- Forum: webERP Discussion (http://www.weberp.org/forum/forumdisplay.php?fid=1)
+--- Forum: Problems / Bugs? (http://www.weberp.org/forum/forumdisplay.php?fid=8)
+--- Thread: Calendar Date Picker - Off by One Month? SOLVED (/showthread.php?tid=7948)



Calendar Date Picker - Off by One Month? SOLVED - VortecCPI - 11-30-2017

Locale USA

Whenever I click on a date field to pop the Calendar Date Picker it is off by one month (+30 days).

[attachment=573]

Is this expected functionality and, if not, how can I make it so the Calendar Date Picker defaults to the date shown in the date fields?

Is this a MiscFunctions.js thing?


RE: Calendar Date Picker - Off by One Month? - falkoner - 11-30-2017

Which script is it, or all? Some scripts have the date field set for 30 days hence or 30 days before.

Tim


RE: Calendar Date Picker - Off by One Month? - VortecCPI - 11-30-2017

After looking at MiscFunctions.js I believe this is a locale issue.

Trying to resolve it now...
(11-30-2017, 05:06 AM)falkoner Wrote: Which script is it, or all? Some scripts have the date field set for 30 days hence or 30 days before.

Tim

It happens in every date field I have tried so far. I assume the calendar should default to the month for the dates shown in the date fields?


RE: Calendar Date Picker - Off by One Month? - falkoner - 11-30-2017

Yes it should. To be honest these days all the browsers support the HTML5 date picker and we probably ought to switch to that. It requires some minor changes to each script to get it to work, it's not a drop in replacement.

I can see the problem with the month getting added on, but mystified as to how it happens. Other date formats appear ok. If you get a solution let me know, otherwise I will look myself, but it won't be tomorrow as I am travelling.

Tim


RE: Calendar Date Picker - Off by One Month? - VortecCPI - 11-30-2017

I made two small changes in MiscFunctions.js and it seems to work as I need it to now.

drawCalendar(md, dt.getFullYear(), dt.getMonth()-1, dt.getDate()+1, dF);

A hack for sure but it gets me where I need to be for now...


RE: Calendar Date Picker - Off by One Month? - falkoner - 12-02-2017

The problem is this then shows the wrong date for d/m/Y date formats.

I need to find time to properly look into this.

Tim
(12-02-2017, 02:56 AM)falkoner Wrote: The problem is this then shows the wrong date for d/m/Y date formats.

I need to find time to properly look into this.

Tim

Turned out to be easier than I expected. Change lines 252/253 of javascripts/MiscFunctions.js to be the following:

m = parseInt(dA[0], 10)-1;
d = parseInt(dA[1], 10);

Thanks
Tim



RE: Calendar Date Picker - Off by One Month? - VortecCPI - 12-02-2017

Thank you Tim!


RE: Calendar Date Picker - Off by One Month? SOLVED - phil - 12-02-2017

Committed to SVN thanks


RE: Calendar Date Picker - Off by One Month? - VortecCPI - 12-03-2017

Thank you both for your help and for committing changes.