Summary: | Week numbering is off by one using ISO Week | ||
---|---|---|---|
Product: | [Applications] calligraplan | Reporter: | Alvaro Soliverez <asoliverez> |
Component: | general | Assignee: | Dag Andersen <dag.andersen> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | 2.7 Pre-Alpha | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Alvaro Soliverez
2013-06-17 19:37:12 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 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. 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) 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. 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. 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 |