GNOME Bugzilla – Bug 757622
Week numbering in year view is incorrect
Last modified: 2017-04-17 18:20:40 UTC
Using a locale with monday is start-of-week (sv_SE) if that matters… Looking at the year view for 2015, you can see that the last week in 2015 (28-31 december) has four days in this year, and is correctly labelled as week #53. Looking at the year view for 2016, you can see that the first week in 2016 (1-3 january) has 3 days in that year, and is incorrectly labelled as week #1, when is actually counted as week #53 in 2015 (as the week has more days in the previos year). The calendar dropdown in the top menu (with week numbers turned on in the tweak tool) shows the correct behavior.
(In reply to Marcus Lundblad from comment #0) > Using a locale with monday is start-of-week (sv_SE) if that matters… > Looking at the year view for 2015, you can see that the last week in 2015 > (28-31 december) has four days in this year, and is correctly labelled as > week #53. > Looking at the year view for 2016, you can see that the first week in 2016 > (1-3 january) has 3 days in that year, and is incorrectly labelled as week > #1, when is actually counted as week #53 in 2015 (as the week has more days > in the previos year). > The calendar dropdown in the top menu (with week numbers turned on in the > tweak tool) shows the correct behavior. I don't believe that's wrong. Where are we getting the definition for week numbering?
(In reply to Erick Pérez Castellanos from comment #1) > (In reply to Marcus Lundblad from comment #0) > > Using a locale with monday is start-of-week (sv_SE) if that matters… > > Looking at the year view for 2015, you can see that the last week in 2015 > > (28-31 december) has four days in this year, and is correctly labelled as > > week #53. > > Looking at the year view for 2016, you can see that the first week in 2016 > > (1-3 january) has 3 days in that year, and is incorrectly labelled as week > > #1, when is actually counted as week #53 in 2015 (as the week has more days > > in the previos year). > > The calendar dropdown in the top menu (with week numbers turned on in the > > tweak tool) shows the correct behavior. > > I don't believe that's wrong. Where are we getting the definition for week > numbering? I beg to differ! :-) See this definition for the ISO week numbering: https://en.wikipedia.org/wiki/ISO_8601#Week_dates So, if you check in the year view for 2016, you'll see that the first week in 2016, the one with Januari 1 in it, has 3 days in the new year (fri, sat, sun) which means that this is counted as the last week of the previous year (52 or 53, in this case 53, as 2015 is a "week 53 year"). Note that this is in a week-starts on monday locale. It might be different in i.e. a en_US locale where the week starts on sunday.
(In reply to Marcus Lundblad from comment #2) > (In reply to Erick Pérez Castellanos from comment #1) > > (In reply to Marcus Lundblad from comment #0) > > > Using a locale with monday is start-of-week (sv_SE) if that matters… > > > Looking at the year view for 2015, you can see that the last week in 2015 > > > (28-31 december) has four days in this year, and is correctly labelled as > > > week #53. > > > Looking at the year view for 2016, you can see that the first week in 2016 > > > (1-3 january) has 3 days in that year, and is incorrectly labelled as week > > > #1, when is actually counted as week #53 in 2015 (as the week has more days > > > in the previos year). > > > The calendar dropdown in the top menu (with week numbers turned on in the > > > tweak tool) shows the correct behavior. > > > > I don't believe that's wrong. Where are we getting the definition for week > > numbering? > > I beg to differ! :-) > See this definition for the ISO week numbering: > https://en.wikipedia.org/wiki/ISO_8601#Week_dates > > So, if you check in the year view for 2016, you'll see that the first week > in 2016, the one with Januari 1 in it, has 3 days in the new year (fri, sat, > sun) which means that this is counted as the last week of the previous year > (52 or 53, in this case 53, as 2015 is a "week 53 year"). > Note that this is in a week-starts on monday locale. > It might be different in i.e. a en_US locale where the week starts on sunday. Ok, I'll read through and update the view as expected. Thank for pointing it out.
I am trying to resolve this. Thanks.
Created attachment 319321 [details] [review] gnome-calendar: Fix week #s in year view Changed year view to use ISO 8601 standard to display the week #s correctly when showing first and last weeks. Year view was always starting week #s as 1, based on Jan 1st, and it kept count the weeks until Dec 31st. But according to ISO 8601 standard, that's not always true, i.e. Jan 1st 2016, is still in the 53th week of 2015, while Dec 31st 2014 is already in the 1st week of 2015. Now the code is using ISO 8601 GDate function to get the correct week number for the first and the last weeks of the year only. Other weeks continue to use the same logic. More about ISO 6801: https://en.wikipedia.org/wiki/ISO_8601#Week_dates
Review of attachment 319321 [details] [review]: I just tried this patch and it mostly works. However, it shows 2017's first week wrongly (it should start with #1, but it actually starts with #53). That should be a small condition check that should be going wrong.
I'd like to point out that this commit message is perfect.
Murphy's Law, I've tested 2016, 2015 and 2014... Let me check it. And thanks! :)
Created attachment 319367 [details] [review] gnome-calendar: Fix week #s in year view Changed year view to use ISO 8601 standard to display the week #s correctly when showing first and last weeks. Year view was always starting week #s as 1, based on Jan 1st, and it kept count the weeks until Dec 31st. But according to ISO 8601 standard, that's not always true, i.e. Jan 1st 2016, is still in the 53th week of 2015, while Dec 31st 2014 is already in the 1st week of 2015. Now the code is using ISO 8601 GDate function to get the correct week number for the first and the last weeks of the year only. Other weeks continue to use the same logic. More about ISO 6801: https://en.wikipedia.org/wiki/ISO_8601#Week_dates
Comment on attachment 319367 [details] [review] gnome-calendar: Fix week #s in year view Thanks! Now, we have to figure out what's going on that 01-01-2017 is displaying as week #52. Didn't see any other issues besides that. Attachment 319367 [details] pushed as c4853dd - gnome-calendar: Fix week #s in year view
I've managed to fix the 01-01-2017 and I compared first and last weeks of years from 2010-2020 and they are all OK. I just need some advice in order to submit this new commit: should I create a new one or should I just use the last one? Thanks.
Ops, I forgot to mention I compared the results with gnome-shell panel calendar.
Created attachment 319615 [details] [review] year-view: Fix for 01-01-2017 date Previous fix was considering Jan 1st and Dec 31st to find the week number, using ISO 8601 standard, and that was causing an issue with some dates like Jan 1st, 2017 which was displaying week# 52 instead of week #1. The issue happened because ISO 8601 always consider Monday as the first weekday, so as Jan 1st, 2017 is a Sunday, it' still considered week# 52 and not week# 1. After checking GtkCalendar code I noticed it uses the same ISO 8601 standard but instead of using Jan 1st or Dec 31st, it always get the week number based on the last day of that week, taking account if the week starts on Sunday or Monday, depending on the locale. In our example, using a calendar based on Sunday, Jan 1st, 2017 is the first day of the week and Jan 7th, 2017 is the last one. Therefore I changed week number code to always use the last day of the week.
Review of attachment 319615 [details] [review]: This patch does not compile against git master.
Created attachment 319869 [details] [review] year-view: Fix for 01-01-2017 date Previous fix was considering Jan 1st and Dec 31st to find the week number, using ISO 8601 standard, and that was causing an issue with some dates like Jan 1st, 2017 which was displaying week# 52 instead of week #1. The issue happened because ISO 8601 always consider Monday as the first weekday, so as Jan 1st, 2017 is a Sunday, it' still considered week# 52 and not week# 1. After checking GtkCalendar code I noticed it uses the same ISO 8601 standard but instead of using Jan 1st or Dec 31st, it always get the week number based on the last day of that week, taking account if the week starts on Sunday or Monday, depending on the locale. In our example, using a calendar based on Sunday, Jan 1st, 2017 is the first day of the week and Jan 7th, 2017 is the last one. Therefore I changed week number code to always use the last day of the week.
Created attachment 320050 [details] [review] year-view: Fix for 01-01-2017 date Previous fix was considering Jan 1st and Dec 31st to find the week number, using ISO 8601 standard, and that was causing an issue with some dates like Jan 1st, 2017 which was displaying week# 52 instead of week #1. The issue happened because ISO 8601 always consider Monday as the first weekday, so as Jan 1st, 2017 is a Sunday, it' still considered week# 52 and not week# 1. After checking GtkCalendar code I noticed it uses the same ISO 8601 standard but instead of using Jan 1st or Dec 31st, it always get the week number based on the last day of that week, taking account if the week starts on Sunday or Monday, depending on the locale. In our example, using a calendar based on Sunday, Jan 1st, 2017 is the first day of the week and Jan 7th, 2017 is the last one. Therefore I changed week number code to always use the last day of the week.
Thanks for working on this issue. Attachment 320050 [details] pushed as 9646d4f - year-view: Fix for 01-01-2017 date