Bug 321290 - Week numbering is off by one using ISO Week
Summary: Week numbering is off by one using ISO Week
Status: RESOLVED FIXED
Alias: None
Product: calligraplan
Classification: Applications
Component: general (show other bugs)
Version: 2.7 Pre-Alpha
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Dag Andersen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-17 19:37 UTC by Alvaro Soliverez
Modified: 2013-11-24 19:17 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alvaro Soliverez 2013-06-17 19:37:12 UTC
The week number either in the calendar grid of the Work & Vacation view or in the Gantt view is off by one.
It shows one less than the week number in KDE's calendar on the system tray.
Today (2013-06-17), it shows week number 24, and KDE's calendar shows 25.

I tried to debug it but couldn't find the area of code where this is being calculated.

Reproducible: Always
Comment 1 Alvaro Soliverez 2013-06-20 03:06:40 UTC
I found it's a problem in KCalendarSystem


const KCalendarSystem * calendar = KGlobal::locale()->calendar();
const int weekNumber = calendar->week( pCellDate );

Example: 2013-06-16 should return 25, but it returns 24.

Locale is set to start week on Sundays
Comment 2 Chusslove Illich 2013-06-20 07:54:07 UTC
But did you also set the "Week number system:" in locale settings? Because
by default it is on "ISO Week", for which it is expressly stated that weeks
start on Monday for the purpose of numbering them. Two other options, "Full
First Week" and "Partial First Week", claim to take into account the set
starting day of the week.
Comment 3 Alvaro Soliverez 2013-06-20 11:35:29 UTC
It returns the correct week number on Mondays, so the problem is on the calculation of the first day of the week, not the starting week.

I forgot to add Monday in my previous example.

Example: 

2013-06-16 should return 25, but it returns 24.
2013-06-17 returns 25 (OK)
Comment 4 Chusslove Illich 2013-07-05 08:05:53 UTC
But what about the "Week number system:" setting, in System Settings "Region
and Language" module? As I explained above, if it is set to default value of
"ISO Week", then Monday is taken as first weekday in week numbering,
regardless of the actual setting of week start day.
Comment 5 Alvaro Soliverez 2013-07-05 11:48:57 UTC
That's the issue then. Calligra Plan and Korganizer are only taking the "First day of week" setting, not realizing that ISO Week numbering system can modify the first day of week too.

Thanks for the clarification. I'll move this back to Calligra, because it has to be fixed there.
Comment 6 Alvaro Soliverez 2013-11-24 19:17:01 UTC
Fixed with these commits

commit e9fef5c56b5135966d209954bafa9bafe7946f1a
Author: Alvaro Soliverez <asoliverez@kde.org>
Date:   Sun Nov 24 15:38:28 2013 -0300

    If using ISO for week numbering, first day of week must be Monday
    Use KLocale for week numbers instead of QDate's week methods
    Patch for KDGantt lib
    REVIEW:114088

commit 1d8e708f591b1b2d2812cfb5ec3df0bc9cb2205e
Author: Alvaro Soliverez <asoliverez@kde.org>
Date:   Sun Nov 24 13:59:01 2013 -0300

    If using ISO for week numbering, first day of week must be Monday
    Use KLocale for week numbers instead of QDate's week methods