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

Behaviour change of QDateTime::setTime

    XMLWordPrintable

Details

    • c3590c76775c889fde13dc155c2a31508db612e9

    Description

      The behaviour of QDateTime::setTime is different in Qt 5.3.2 compared to Qt 5.1.1 and Qt 4 in general.

      In Qt 5.1.1 the QDateTime internal time was set to the provided time, no matter if it was valid or not.
      In Qt 5.3. though the time is only accepted if it is valid. If the time is not valid while the date is, then the time will be set to midnight.

      Therefore the behaviour is different, while the documentation remains the same:

      Sets the time part of this datetime to time.

      For example:

      QDateTime dt;
      dt.setDate(QDate(2014, 12, 10));
      
      QTime invalid_time = QTime(99, 99, 99);
      
      dt.setTime(invalid_time);
      
      QVERIFY(dt.isValid()); // false on Qt 5.1.1 and true on Qt 5.3.2
      QVERIFY(dt.getTime().isValid()); // false on Qt 5.1.1 and true on Qt 5.3.2
      QCOMPARE(dt.getTime(), invalid_time); // true on Qt 5.1.1 false on Qt 5.3.2
      

      So either there is a Bug in the code or the documentation needs to be updated to reflect the new behaviour.

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            mfuchs Matthias Fuchs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes