From 5ee3a6fac4c1a2cd3802809537ffb63003a48941 Mon Sep 17 00:00:00 2001 From: guenter-wolf Date: Thu, 28 Aug 2014 16:39:31 -0700 Subject: [PATCH] bug #2506 Datepicker displays wrong week numbers fix bug #2506 Datepicker displays wrong week numbers. also fixed another week number bug: It calculates the ISO 8601 Week Number only for the first row of a month and for the following rows of this month it just increments the week number. This generally works, but it may create wrong week numbers for December and January. --- src/datepicker/datepicker.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/datepicker/datepicker.js b/src/datepicker/datepicker.js index 15198d5d7e..2755ef90f3 100644 --- a/src/datepicker/datepicker.js +++ b/src/datepicker/datepicker.js @@ -259,10 +259,11 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst if ( scope.showWeeks ) { scope.weekNumbers = []; - // 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); var numWeeks = scope.rows.length; - while( scope.weekNumbers.push(weekNumber++) < numWeeks ) {} + for (var r = 0; r < numWeeks; r++) { + // use date at middle of the row (3) instead of 0 to avoid problems when first day is Sunday + scope.weekNumbers.push(getISO8601WeekNumber(scope.rows[r][3].date)); + } } };