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

QDateTime(1/1/1970 00:00:00) compares equal to QDateTime()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 5.14.0
    • 5.12.2
    • Core: Date/Time
    • None
    • All
    • 60deb69034e3d3ac36213ad8c36042ad57c495f7

    Description

      The QDateTime for midnight Jan 1 1970, and that datetime to the second alone, compares equal to the invalid datetime produced by QDateTime().

      QDateTime::fromString("01/01/1970 00:00:00", "dd/MM/yyyy hh:mm:ss").isValid() => true

      QDateTime::fromString("01/01/1970 00:00:00", "dd/MM/yyyy hh:mm:ss") == QDateTime() => true

      See https://forum.qt.io/topic/112474/dealing-with-qdatetime-and-january-1-1970-at-00-00-00 for discussion.

      This is in contravention to docs

      https://doc.qt.io/qt-5/qdatetime.html#operator-eq-eq

       bool QDateTime::operator==(const QDateTime &other) const

      Returns true if this datetime is equal to the other datetime; otherwise returns false.

      Since 5.14, all invalid datetimes are equal to one another and differ from all other datetimes.

      since a valid datetime is comparing equal to an invalid one.

      We realise this will be connected to the fact that the seconds elapsed since 1970 comes out at zero, but it is nasty behaviour

       

      Attachments

        Issue Links

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

          Activity

            People

              Eddy Edward Welbourne
              jonbrave J Barchan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes