Permalink
Browse files

fixed calculation of first / last days of week during daylight saving…

…s time
  • Loading branch information...
1 parent 52c41fa commit 2694aff86016fb31d00d332a90dffc76f09c8ff8 @robmonie robmonie committed Mar 8, 2010
Showing with 14 additions and 20 deletions.
  1. +14 −20 jquery.weekcalendar.js
View
34 jquery.weekcalendar.js
@@ -1182,37 +1182,31 @@
/*
* returns the date on the first millisecond of the week
*/
- /* _dateFirstDayOfWeek : function(date) {
+
+ _dateFirstDayOfWeek : function(date) {
var self = this;
var midnightCurrentDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
- var millisToSubtract = self._getAdjustedDayIndex(midnightCurrentDate) * 86400000;
- return new Date(midnightCurrentDate.getTime() - millisToSubtract);
+ var adjustedDate = new Date(midnightCurrentDate);
+ adjustedDate.setDate(adjustedDate.getDate() - self._getAdjustedDayIndex(midnightCurrentDate));
- },*/
+ return adjustedDate;
- _dateFirstDayOfWeek : function(date) {
- var midnightCurrentDate = new Date(date.getFullYear(), date.getMonth(), date.getDate() - date.getDay());
- return midnightCurrentDate;
- },
+ },
/*
* returns the date on the first millisecond of the last day of the week
*/
_dateLastDayOfWeek : function(date) {
- var midnightCurrentDate = new Date(date.getFullYear(), date.getMonth(), date.getDate() + (6 - date.getDay()));
- return midnightCurrentDate;
- },
- /*
- * returns the date on the first millisecond of the last day of the week
- */
- /*_dateLastDayOfWeek : function(date) {
+
var self = this;
var midnightCurrentDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
- var millisToAdd = (6 - self._getAdjustedDayIndex(midnightCurrentDate)) * MILLIS_IN_DAY;
- return new Date(midnightCurrentDate.getTime() + millisToAdd);
- },
- */
+ var adjustedDate = new Date(midnightCurrentDate);
+ adjustedDate.setDate(adjustedDate.getDate() + (6 - this._getAdjustedDayIndex(midnightCurrentDate)));
+
+ return adjustedDate;
+
+ },
/*
* gets the index of the current day adjusted based on options
@@ -1296,7 +1290,7 @@
var curChar = format.charAt(i);
if ($.isFunction(this._replaceChars[curChar])) {
var res = this._replaceChars[curChar](date, options);
- console.log(res);
+
if (res === '00' && options.alwaysDisplayTimeMinutes === false) {
//remove previous character
returnStr = returnStr.slice(0, -1);

0 comments on commit 2694aff

Please sign in to comment.