Skip to content

Commit

Permalink
bug angular-ui#2506 Datepicker displays wrong week numbers
Browse files Browse the repository at this point in the history
The datepicker displays wrong week numbers if the starting-day is 0 (Sunday),
because it uses the first of the row to determine the weeknumber of the corresponding row.
According to ISO 8601 the week starts on Monday and ends on Sunday.
Consequently the datapicker will display e.g. for the week Sun Aug 17 - Sat Aug 23 the number of the week that ended on Sun Aug 17 and not the week that starts on Mon Aug 18.
Using the date at middle of the row will display the correct week number regardless of whether the week display starts with a Sunday or a Monday.
  • Loading branch information
guenter-wolf committed Jul 26, 2014
1 parent 7512b93 commit cbfa8b9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst

if ( scope.showWeeks ) {
scope.weekNumbers = [];
var weekNumber = getISO8601WeekNumber( scope.rows[0][0].date ),
// use date at middle of the row (3) instead of 0 to avoid problems when first day is Sunday
var weekNumber = getISO8601WeekNumber( scope.rows[0][3].date ),
numWeeks = scope.rows.length;
while( scope.weekNumbers.push(weekNumber++) < numWeeks ) {}
}
Expand Down

0 comments on commit cbfa8b9

Please sign in to comment.