Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-50273

QDate returns wrong week number for last 4 days of 2020

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.6.0
    • 5.6.0 Beta
    • Core: Date/Time
    • 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

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            mck182 Martin Klapetek
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes