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

Generating QDateTime with invalid transition hour is no more possible

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Invalid
    • Affects Version/s: 5.15.1
    • Fix Version/s: None
    • Component/s: Core: Date/Time
    • Labels:
      None

      Description

      Some old databases might contain invalid timestamp values due to summer time transition, i.e. "2015-03-29 02:09:11.001". The date component is valid, but the time not. QDateTime could handle this value in the past.

      According to the documentation of function QDateTime::isValid()) handling of such timestamp should be still possible:

      Time transition hour, i.e. if the transition is at 2am and the clock goes forward to 3am then the time from 02:00:00 to 02:59:59.999 is considered to be invalid. 

      This has been broken in the latest version which makes the auto correction impossible.

      The following snippet explains the differences:

      const QString strDT = "2015-03-29 02:09:11.001";
      QDateTime dateAndTime = QDateTime::fromString(strDT,"yyyy-MM-dd hh:mm:ss.zzz");
      dateAndTime.isNull() -> false in Qt 5.13.2, true in Qt 5.15.1
      dateAndTime.isValid() -> false in both
      dateAndTime.date().isValid() -> true in Qt 5.13.2 and false in Qt 5.15.1 

      The following also does not work. Value returned is not null, but isValid() returns true (which is definitely wrong)

      QDateTime dateAndTime = QDateTime(QDate::fromString("2019-03-12","yyyy-MM-dd"),QTime::fromString("02:09:11.001","hh:mm:ss.zzz")); 

        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:
              rusakan Andrzej Rusak
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes