[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [plasma-framework] src/declarativeimports/calendar: [calendar] Always start counting weeks from Mond
From: Martin Klapetek <mklapetek () kde ! org>
Date: 2015-06-11 23:11:24
Message-ID: E1Z3Bd6-0006ps-7L () scm ! kde ! org
[Download RAW message or body]
Git commit bc0280ddb0b1333aee1a8bc0322ba61327ef015a by Martin Klapetek.
Committed on 11/06/2015 at 23:11.
Pushed by mklapetek into branch 'master'.
[calendar] Always start counting weeks from Monday
Sometimes the first day in the grid can be Sunday, but the week number
must always be counted from Monday in that week
BUG: 349044
Change-Id: I903650fcaadb4fd78764ad6a8bb1e219261c791b
FIXED-IN: 5.11
M +13 -1 src/declarativeimports/calendar/calendar.cpp
http://commits.kde.org/plasma-framework/bc0280ddb0b1333aee1a8bc0322ba61327ef015a
diff --git a/src/declarativeimports/calendar/calendar.cpp b/src/declarativeimports/calendar/calendar.cpp
index 46395f9..c462dbd 100644
--- a/src/declarativeimports/calendar/calendar.cpp
+++ b/src/declarativeimports/calendar/calendar.cpp
@@ -261,8 +261,20 @@ void Calendar::updateData()
}
const int numOfDaysInCalendar = m_dayList.count();
+ // Week numbers are always counted from Mondays
+ // so find which index is Monday
+ int mondayOffset = 0;
+ if (!m_dayList.isEmpty()) {
+ const DayData &data = m_dayList.at(0);
+ QDate firstDay(data.yearNumber, data.monthNumber, data.dayNumber);
+ // If the first day is not already Monday, get offset for Monday
+ if (firstDay.dayOfWeek() != 1) {
+ mondayOffset = 8 - firstDay.dayOfWeek();
+ }
+ }
+
// Fill weeksModel with the week numbers
- for (int i = 0; i < numOfDaysInCalendar; i += 7) {
+ for (int i = mondayOffset; i < numOfDaysInCalendar; i += 7) {
const DayData &data = m_dayList.at(i);
m_weekList.append(QDate(data.yearNumber, data.monthNumber, data.dayNumber).weekNumber());
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic