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

QDate::from string gives wrong year

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.12.1
    • Fix Version/s: None
    • Component/s: Core: Date/Time
    • Labels:
      None
    • Platform/s:
      Windows

      Description

      When system locale short date is set to show the year with two digits only the QDate::fromString() conversion results in a wrong century (1900 instead of 2000).

      // System local short date: dd-MMM-yy
      QDate d1= QDate::currentDate();
      QString s1 = d1.toString(Qt::SystemLocaleShortDate); // "11-Mrz-19"
      QDate d2= QDate::fromString(s1, Qt::SystemLocaleShortDate);
      QString s2 = d2.toString("dd.MM.yyyy"); // "11.03.1919"
      

      In 2019 the base century should be 2000 for two digit year dates.

        Attachments

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

          Activity

            People

            Assignee:
            Eddy Edward Welbourne
            Reporter:
            elgerton Martin Elger
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes