summaryrefslogtreecommitdiffstats
path: root/src/corelib/time/qdatetime.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/time/qdatetime.cpp')
-rw-r--r--src/corelib/time/qdatetime.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp
index 6b6674dcce..94ea0112d4 100644
--- a/src/corelib/time/qdatetime.cpp
+++ b/src/corelib/time/qdatetime.cpp
@@ -735,14 +735,12 @@ int QDate::weekNumber(int *yearNumber) const
// This could be replaced by use of QIso8601Calendar, once we implement it.
// The Thursday of the same week determines our answer:
- QDate thursday(addDays(4 - dayOfWeek()));
- int year = thursday.year();
- // Week n's Thurs's DOY has 1 <= DOY - 7*(n-1) < 8, so 0 <= DOY + 6 - 7*n < 7:
- int week = (thursday.dayOfYear() + 6) / 7;
-
+ const QDate thursday(addDays(4 - dayOfWeek()));
if (yearNumber)
- *yearNumber = year;
- return week;
+ *yearNumber = thursday.year();
+
+ // Week n's Thurs's DOY has 1 <= DOY - 7*(n-1) < 8, so 0 <= DOY + 6 - 7*n < 7:
+ return (thursday.dayOfYear() + 6) / 7;
}
static bool inDateTimeRange(qint64 jd, bool start)