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

QDateTime::secsTo returns an int that overflows for large timespans

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Out of scope
    • P4: Low
    • 5.0.0
    • 3.x
    • Core: Date/Time
    • None

    Description

      Which can be seen by running the following example:

      #include <QtCore>

      int main(int argc, char *argv[])
      {
      QDateTime dt1970(QDate(1,1,1970));

      QDateTime dt;
      time_t tt = 0x7FFFFFFF;
      // add 365 days
      for (int i = 0; i < 365; ++i, tt += 3600 * 24)

      { dt.setTime_t(tt); qDebug() << dt.toString() << dt1970.secsTo(dt) << (uint)dt1970.secsTo(dt); }

      }

      secsTo should return an unsigned int, or even better an unsigned 64bit integer.

      Attachments

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

        Activity

          People

            stormols Marius Storm-Olsen
            vhilshei Volker Hilsheimer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes