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

[Reg 6.7.2 -> 6.8.0][macOS] QLocale::LongFormat no longer produces reversible conversion between QDateTime and QString

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 6.8.0
    • Core: Locales (i18n)
    • macOS 13.5.2 (M1 CPU), Xcode 14.3, en_AU system locale
    • All, macOS
    • 25
    • Foundation Sprint 118, Foundation Sprint 119, Foundation Sprint 120, Foundation Sprint 121, Foundation Sprint 122

    Description

      Code

      #include <QDateTime>
      #include <QLocale>
      
      int main()
      {
          QLocale deLocale{QLocale::German, QLocale::Germany};
      
          const auto dt = QDateTime(QDate(2024, 05, 06), QTime(12, 34));
          const auto str = deLocale.toString(dt, QLocale::LongFormat);
          const auto parsed = deLocale.toDateTime(str, QLocale::LongFormat);
      
          qDebug() << "Original timestamp:" << dt;
          qDebug() << "Long format string:" << str;
          qDebug() << "Parsed timestamp:" << parsed;
      
          Q_ASSERT(parsed.isValid());
      }
      

       

      Correct result (Qt 6.7.2, macOS)

      Original timestamp: QDateTime(2024-05-06 12:34:00.000 GMT+8 Qt::LocalTime)
      Long format string: "Montag, 6. Mai 2024 12:34:00 GMT+8"
      Parsed timestamp: QDateTime(2024-05-06 12:34:00.000 GMT+8 Qt::LocalTime)
      

       

      Wrong result (Qt 6.8.0, macOS)

      Original timestamp: QDateTime(2024-05-06 12:34:00.000 GMT+8 Qt::LocalTime)
      Long format string: "Montag, 6. Mai 2024 12:34:00 Westaustralische Normalzeit"
      Parsed timestamp: QDateTime(Invalid)
      

      Assertion fails

       

      For comparison (Qt 6.7.2 and 6.8.0, Windows 10 22H2)
      I'm not sure whether this is considered fully correct or not.

      • The result of QLocale::toDateTime() is correct, but
      • The result of QLocale::toString() contains a mixture of German and English
      Original timestamp: QDateTime(2024-05-06 12:34:00.000 W. Australia Standard Time Qt::LocalTime)
      Long format string: "Montag, 6. Mai 2024 12:34:00 W. Australia Standard Time"
      Parsed timestamp: QDateTime(2024-05-06 12:34:00.000 W. Australia Standard Time Qt::LocalTime)
      

      Attachments

        Issue Links

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

          Activity

            People

              Eddy Edward Welbourne
              skoh-qt Sze Howe Koh
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change