thekingsimo / jquery-week-calendar

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

March 20, 2010 doesn't appear on calendar #51

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
If you go to the week of March 14 - 20, 2010 you can see all the days are
off by one (eg: Sunday the 14th is listed as a Monday). 

In general, the _dateFirstDayOfWeek() and _dateLastDayOfWeek() functions
aren't correct for the weeks immediately before or after the time daylight
savings begins.

I changed lines 987 - 1001 to the following, which I think fixed the problem:

_dateFirstDayOfWeek : function(date) {

    var midnightCurrentDate = new Date(date.getFullYear(), date.getMonth(),
date.getDate());
    var currentDayOfWeek = midnightCurrentDate.getDay();
    var firstDayOfWeek = new Date(date);
    firstDayOfWeek.setDate(midnightCurrentDate.getDate() - currentDayOfWeek);
    return firstDayOfWeek;
},

_dateLastDayOfWeek : function(date) {
    var midnightCurrentDate = new Date(date.getFullYear(), date.getMonth(),
date.getDate());
    var currentDayOfWeek = midnightCurrentDate.getDay();
    var lastDayOfWeek = new Date(date);
    lastDayOfWeek.setDate(midnightCurrentDate.getDate() +
(6-currentDayOfWeek));
    return lastDayOfWeek;

},

Original issue reported on code.google.com by gkj4...@gmail.com on 27 Jul 2009 at 4:31

GoogleCodeExporter commented 8 years ago
In the code I posted above
    var firstDayOfWeek = new Date(date);
should actually be
    var firstDayOfWeek = new Date(midnightCurrentDate);

likewise change
    var lastDayOfWeek = new Date(date);
to
    var lastDayOfWeek = new Date(midnightCurrentDate);

Original comment by gkj4...@gmail.com on 6 Aug 2009 at 6:47

GoogleCodeExporter commented 8 years ago

Original comment by robmo...@gmail.com on 10 Aug 2009 at 12:55