Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird DatePicker behavior with some dates #47

Open
lenore-corbeaux opened this issue Sep 29, 2009 · 1 comment
Open

Weird DatePicker behavior with some dates #47

lenore-corbeaux opened this issue Sep 29, 2009 · 1 comment

Comments

@lenore-corbeaux
Copy link

Hi there,

As mentionned here http://github.com/anutron/clientcide/issuesearch?state=open&q=datepicker#issue/15 and here http://github.com/anutron/clientcide/issuesearch?state=open&q=datepicker#issue/26 some dates break the DatePicker.

I'm sure that's an issue, as you can reproduce the bug in the tutorial/demo section here :
http://www.clientcide.com/wiki/cnet-libraries/09-forms/02-datepicker

Try to type any november date prior to 2009, like 2007-11-07, and all calendar's cases will be filled by the same number (28 for this example). Works the same way on FF or IE.

As the previous issues were posted several months ago, is there a chance to get an answer, or even an hint to fix the problem ourselves ?

@rrehbein
Copy link

The issue is with Daylights savings.
ie: Nov 1, 2009 to Nov 2nd, Daylights savings means Nov 1 + 24 hours of seconds gets you to Nov 1, 23:00. Because it sets the hour, Nov 1 23:00 becomes Nov 1, 00:00, and you end up repeating the date.

Ended up adding a bit of code to fillCalendar method:

@@ -13629,13 +13629,15 @@ var DatePicker;
                        });
                        document.id(this.rows[0].getElements('td')[1]).empty().adopt(monthyr);
                        var atDate = startDate.clone();
+                       // deal with a daylight savings time issue, see: Nov 1st, 2009
+                       var incrementTime = Date.units.day() + (Date.units.hour() * 2);
                        this.rows.each(function(row, i){
                                if (i < 2) return;
                                row.getElements('td').each(function(td){
                                        atDate.set('hours', hours);
                                        td.firstChild.data = atDate.getDate();
                                        td.refDate = atDate.getTime();
-                                       atDate.setTime(atDate.getTime() + Date.units.day());
+                                       atDate.setTime(atDate.getTime() + incrementTime);
                                }, this);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants