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

QDate::fromString() fails on isolated dates on macOS with TZ=Europe/Lisbon

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.15.0, 6.0.0
    • Fix Version/s: 6.1.2, 6.2.0 Alpha
    • Component/s: Core: Date/Time
    • Labels:
      None
    • Environment:
      macOS 11.2 Big Sur
      Apple clang version 12.0.0 (clang-1200.0.32.29)
      Target: x86_64-apple-darwin20.3.0
      Thread model: posix
    • Platform/s:
      macOS
    • Commits:
      f9469990d0fb1ae9444d415390ec8be483ec4ab3 (qt/qtbase/dev) 02c7b658f6246220fa926abb2b69779d2ffe77f1 (qt/qtbase/6.1) 0c47482edefd35f5d7413a970d8dd088e7e3b743 (qt/qtbase/6.2) 54181e1b757a9ef42b446afb230fc2317fc23c37 (qt/tqtc-qtbase/5.15)

      Description

      With Qt 5.15.0 or Qt 6.0.0 on macOS 11.2 Big Sur, these conversions yield invalid dates:

      qDebug() << QDate::fromString("1978-04-02", "yyyy-MM-dd");
      qDebug() << QDate::fromString("02-04-1978", "dd-MM-yyyy");
      

      This behaviour occurs for at least three other dates, i.e.,  1977-03-27, 1978-04-02, 1979-04-01, 1980-03-30. This can be checked with the following code (compilable example attached):

      QString format("yyyy-MM-dd");
      for (int year=1930; year <= 2030; ++year)
      {
      	QDate date(year,1,1);
      	while (date != QDate(year+1,1,1))
      	{
      		QString str = date.toString(format);
      		QDate converted = QDate::fromString(str, format);
      		if (converted != date)
      			qDebug() << date << converted;
      		date = date.addDays(1);
      	}
      }
      

       

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              Eddy Edward Welbourne
              Reporter:
              jorge Paulo Ferreira
              PM Owner:
              Vladimir Minenko Vladimir Minenko
              RnD Owner:
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews