Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.6.0 Beta
-
None
-
Linux; Qt 5.5.1 and Qt 5.6beta
Description
QDate(2020, 12, 31).weekNumber() returns "1" while it should return "53".
The 31st December 2020 is on Thursday, according to [1] - "If 31 December is on a Monday, Tuesday or Wednesday, it is in week 01 of the next year. If it is on a Thursday, it is in week 53 of the year just ending".
Furthermore, QDate(2021, 1, 1).weekNumber() (the next day) actually returns "53", which is correct. See below.
[1] - https://en.wikipedia.org/wiki/ISO_week_date#Last_week
—
Attached is a simple test case which outputs the QDate week number of the last week in year 2020, here's the output:
(390) main: Week for QDate("2020-12-26") is 52
(390) main: Week for QDate("2020-12-27") is 52
(390) main: Week for QDate("2020-12-28") is 1
(390) main: Week for QDate("2020-12-29") is 1
(390) main: Week for QDate("2020-12-30") is 1
(390) main: Week for QDate("2020-12-31") is 1
(390) main: Week for QDate("2021-01-01") is 53
(390) main: Week for QDate("2021-01-02") is 53
(390) main: Week for QDate("2021-01-03") is 53
(390) main: Week for QDate("2021-01-04") is 1
(390) main: Week for QDate("2021-01-05") is 1
Attachments
For Gerrit Dashboard: QTBUG-50273 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
145017,2 | QDate: fix calculation of the week number for the last days of 2020 | 5.6 | qt/qtbase | Status: MERGED | +2 | 0 |