engineer9090909090909090 / jquery-datepicker

Automatically exported from code.google.com/p/jquery-datepicker
0 stars 0 forks source link

Enter 29.2.2012 #262

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Enter 29.2.2012 translate in 1.3.2012

Error in date.js
//---
        for (var i=0; i<order.length; i++) {
            var res = result[i+1];
            switch(order[i]) {
                case 'd':
                    d.setDate(res);
                    break;
                case 'm':
                    d.setMonth(Number(res)-1);
                    break;
                case 'M':
                    for (var j=0; j<Date.abbrMonthNames.length; j++) {
                        if (Date.abbrMonthNames[j].toLowerCase() == res) break;
                    }
                    d.setMonth(j);
                    break;
                case 'y':
                    d.setYear(res);
                    break;
            }
        }
//---

Need replace
//---
        for (var i=0; i<order.length; i++) {
            var res = result[i+1];
            switch(order[i]) {
                case 'm':
                    d.setMonth(Number(res)-1);
                    break;
                case 'M':
                    for (var j=0; j<Date.abbrMonthNames.length; j++) {
                        if (Date.abbrMonthNames[j].toLowerCase() == res) break;
                    }
                    d.setMonth(j);
                    break;
                case 'y':
                    d.setYear(res);
                    break;
            }
        }
        for (var i=0; i<order.length; i++) {
            var res = result[i+1];
            if (order[i] == 'd') {
                    d.setDate(res);
            }
        }
//--

because first set date but year not set (1970 not Leap)

Original issue reported on code.google.com by myy...@gmail.com on 26 Jan 2011 at 5:28

GoogleCodeExporter commented 8 years ago
I see the issue. Because the year is set last then the date has already been 
switched to the 1st March (since there was no 29th Feb in the year that the 
date originally represented...
I'm not sure your solution is optimal - it seems to be it would be better in 
the first loop to grab out year, month and date and then to apply these values 
to the new date afterwards in the order year, month, date...
I'll implement this when I have a chance to work on the date picker next (may 
not be too soon - thanks)

Original comment by kelvin.l...@gmail.com on 27 Jan 2011 at 9:54

GoogleCodeExporter commented 8 years ago
By the way - thanks for the bug report and patch!

Original comment by kelvin.l...@gmail.com on 27 Jan 2011 at 9:59

GoogleCodeExporter commented 8 years ago
Please)

Original comment by myy...@gmail.com on 5 Feb 2011 at 1:17

GoogleCodeExporter commented 8 years ago
thanks!

Original comment by mixd...@gmail.com on 27 Sep 2011 at 12:55