Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/oakey-b1/horde
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Schneider <jan@horde.org>
  • Loading branch information
yunosh committed Jan 25, 2016
2 parents 3a718a2 + 4adfa2e commit 97fb134
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions framework/Core/js/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,20 @@ var Horde_Calendar =
},

// http://javascript.about.com/library/blstdweek.htm
// The first week of a year is the week that contains the first Thursday of the year (and, hence, always contains 4 January).
// see: https://en.wikipedia.org/wiki/ISO_week_date
weekOfYear: function(d)
{
var newYear = new Date(d.getFullYear(), 0, 1),
day = newYear.getDay();
var newYear = new Date(d.getFullYear(), 0, 4),
day = newYear.getDay(), weekNr;
if (this.firstDayOfWeek !== 0) {
day = ((day + (7 - this.firstDayOfWeek)) % 7);
}
return Math.ceil((((d - newYear) / 86400000) + day + 1) / 7);
weekNr = Math.ceil((((d - newYear) / 86400000) + day + 1) / 7);
if (weekNr == 0) {
return this.weekOfYear(new Date(d.getFullYear()-1, 11, 31));
}
return weekNr;
},

draw: function(timestamp, init)
Expand Down

0 comments on commit 97fb134

Please sign in to comment.