Skip to content

Commit cbfa8b9

Browse files
committed
bug angular-ui#2506 Datepicker displays wrong week numbers
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.
1 parent 7512b93 commit cbfa8b9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/datepicker/datepicker.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
259259

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

0 commit comments

Comments
 (0)