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

QDate::from string gives wrong year

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Duplicate
    • 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

          Issue Links

          For Gerrit Dashboard: QTBUG-74323
          # Subject Branch Project Status CR V

            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:
                Resolved:

                  Gerrit Reviews

                  There is 1 open Gerrit change