-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Datepicker displays wrong week numbers #2506
Comments
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.
I have created a pull request for this bug fix: |
fix bug angular-ui#2506 Datepicker displays wrong week numbers. also fixed some white space problems jshint was complaining about.
fix bug angular-ui#2506 Datepicker displays wrong week numbers also fixing the unit test. correct ISO week numbers are here: http://www.epochconverter.com/date-and-time/weeknumbers-by-year.php?year=2010
fix bug angular-ui#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.
This is another bug: |
@pkozlowski-opensource @chrisirhc |
+1 Need this fix |
+1 on this item - any chance we get that pull request accepted if it fixes these issues? |
+1 need this very badly |
+1 much needed here as well! |
+1 Need this fix! :) |
+1 - It's a bug fix, why not merge it? |
I've reviewed the PR and it needs some work before we can get it merged in. |
Since I had no idea of knowing when the adjustments would be made here I made a new PR that covers the issues that were still relevant: #3158. Starting day seemed to have already been fixed in the meantime. |
Hey guys, Do you have any updates on this bug? When do you plan to fix it? |
@yuyokk I still have a PR outstanding for this, but as you can read in the comments I'm confused by the conflict in specs (must adhere to ISO standards vs must allow sunday as the week's first day). I don't know how to solve that, it seems more like a business decision to me than something code can easily fix. |
@picodealion I see what you mean. I appreciate your answer. Thanks. |
Is there any way to get rid of that last week? For example, in the last image above, the last row on the January 2016 calendar is not even January, it's February. |
@chinchan awesome ! |
The datepicker displays wrong week numbers if the starting-day is 0 (Sunday).
Please compare the week numbers of angularjs-ui bootstrap Inline Datepicker at:
http://angular-ui.github.io/bootstrap/
with the ISO 8601 conform week numbers at:
http://www.epochconverter.com/date-and-time/weeknumbers-by-year.php
The angularjs-ui datepicker displays e.g. for Tue Aug 19 2014 the week number 33,
but the ISO 8601 conform week number is 34.
The problem seems to be that the datepicker uses the first day of the row in the calendar grid to determine the week number of the corresponding row.
This leads to wrong results if the first day of the row is Sunday (which is the datepicker default starting-day).
According to ISO 8601 the week starts on Monday and ends on Sunday.
Consequently the datapicker will display 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.
However, please note that the Popup Datepicker at
http://angular-ui.github.io/bootstrap/ displays the correct week number, since the startingDay is 1 (Monday).
Suggested Solution:
Use the day in the middle of the row to determine the week number of the corresponding row, i.e. replace in datepicker.js the line:
var weekNumber = getISO8601WeekNumber( scope.rows[0][0].date )
with:
var weekNumber = getISO8601WeekNumber( scope.rows[0][3].date )
This will display the correct week number regardless of whether the week display starts with a Sunday or a Monday.
The text was updated successfully, but these errors were encountered: