Javascript Dates in January not working - FIXED IN v3.4

Post Reply
RWAP
Site Admin
Posts: 750
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Javascript Dates in January not working - FIXED IN v3.4

Post by RWAP » Wed Jan 02, 2013 9:43 am

There is a horrendous bug in the class\Date.php, in that the code to return a javascript formatted date does not work in January.

Find:

Code: Select all

    static public function javascriptFormated($d){
        $parts = preg_split("(/|-)", $d);
        return ltrim($parts[0],'0').','.ltrim(($parts[1]-1),'0').','.ltrim($parts[2],'0').',0,1,0,0';
    }
Change this to:

Code: Select all

    static public function javascriptFormated($d){
        $parts = preg_split("(/|-)", $d);
        $month=ltrim(($parts[1]-1),'0');
        if ($month=='') $month=0;
        return ltrim($parts[0],'0').','.$month.','.ltrim($parts[2],'0').',0,1,0,0';
    }
Without this change, the date is returned as 2013,,2,0,1,0,0 which breaks the javascript - it should of course (for today) be 2013,0,2,0,1,0,0

bamse
Posts: 220
Joined: Mon Feb 06, 2012 12:05 pm
Contact:

Re: Javascript Dates in January not working

Post by bamse » Thu Jan 03, 2013 8:46 am

How does this bug show?

As far as I understand that's for the datepicker, right? Seems to work here without any changes, e.g. in offerForm.

RWAP
Site Admin
Posts: 750
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: Javascript Dates in January not working

Post by RWAP » Thu Jan 03, 2013 9:06 am

It all depends on the setup of your site - it only affects the datepicker on standard Enuuk.

Where it showed on my site was on the user registration page - it stopped the captcha code from displaying (as I use a different captcha code which is written in javascript and loaded after the datepicker code).

You may find that the form validation in global.js does not work either as a result of this bug.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest