webERP Forum

Full Version: Calendar Date Picker - Off by One Month? SOLVED
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
Which script is it, or all? Some scripts have the date field set for 30 days hence or 30 days before.

Tim
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?
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
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...
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
Thank you Tim!
Committed to SVN thanks
Thank you both for your help and for committing changes.