SankhaUI / jquery-datepicker

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

selectWeek error when picking 1st April 2013 - 4th April 2013 #362

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
With selectWeek() click any day between 1st to 4th April with 1st day of week 
set to Saturday

What is the expected output? What do you see instead?
Should highlight week commencing 30th March and select date 30/3/13, but it 
actually highlights the week before (23/4 - 29/4/2013) and selects 29/03/2013

Please provide a URL to a page displaying the problem.
Can't do that as it's behind a login, but attached screenshots show the problem

What version of the datepicker are you using? On what operating system? And 
Which Browser?
datePicker v 2. OS Windows 7. Browser Firefox 18, Chrome 23, IE 9

Please provide any additional information below.

Original issue reported on code.google.com by philpar...@gmail.com on 11 Jan 2013 at 9:58

Attachments:

GoogleCodeExporter commented 9 years ago
We had the same issue. It was because of timezone change during that week. The 
addDays method in date.js fails to take timezone change into consideration. 
Change the following code in date.js to fix the issue.

From    
add("addDays", function(num) {
    //this.setDate(this.getDate() + num);
    this.setTime(this.getTime() + (num*86400000) );
    return this;
});

To
add("addDays", function(num) {
    //Get the time zone offset for the time
    var diff = (this.getTimezoneOffset());
    this.setTime(this.getTime() + (num*86400000) );
    //Get the time zone offset for the new time
    var diff2 = this.getTimezoneOffset();
    //If timezone offset is different, happens when time zone changes for e.g. EST to EDT
    if(diff2!=diff){
        //Adjust the difference
        this.setTime(this.getTime() + ((diff2-diff)*60*1000));
    }
    return this;
});

Original comment by tnlk...@gmail.com on 18 Mar 2013 at 6:37

GoogleCodeExporter commented 9 years ago
Thanks! That sounds like a good solution to a problem which has been causing 
lots of people trouble for a long time. Added to the plugin:

https://github.com/vitch/jquery-methods/commit/e02cfc83280686785b721b58012169cdb
f92d456
https://github.com/vitch/jQuery-datepicker/commit/5ec5b66a683690504bb1205e76cabe
5be93e67aa

Original comment by kelvin.l...@gmail.com on 24 Mar 2013 at 10:17

GoogleCodeExporter commented 9 years ago
Great solution - Thanks for posting it. :-)

Original comment by p...@i2in.com on 25 Mar 2013 at 12:55