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

Wrong result of QDateTime::addSecs for UTC offset time zones

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 5.5.0
    • 5.4.0
    • Core: Date/Time
    • None
    • Win 8.1
    • 3b36a550b04fbdfca835002c9c090be8099afa7f

    Description

      addSesc/addMSecs returns wrong result for date times with "UTC+-HH:mm" time zones. The time zone is valid and listed in availableTimeZoneIds.

      #include <QDateTime>
      #include <QTimeZone>
      #include <QDebug>
      
      int main(int argc, char *argv[])
      {
      	QTimeZone tz("UTC+03:00");
      	qDebug() << "tz:" << tz;
      	QDateTime t1(QDate(2010, 6, 1), QTime(0, 0, 0), tz);
      	QDateTime t2 = t1.addSecs(0);
      	QDateTime t3 = t1.addSecs(3600);
      	qDebug() << "t1:" << t1 << "msecs:" << t1.toMSecsSinceEpoch();
      	qDebug() << "t2:" << t2 << "msecs:" << t2.toMSecsSinceEpoch();
      	qDebug() << "t3:" << t3 << "msecs:" << t3.toMSecsSinceEpoch();
      	return 0;
      }
      

      result

      tz: QTimeZone("UTC+03:00")
      t1: QDateTime("2010-06-01 00:00:00.000 UTC+03:00 Qt::TimeZone UTC+03:00") msecs: 1275350400000
      t2: QDateTime("2010-06-01 03:00:00.000 UTC+03:00 Qt::TimeZone UTC+03:00") msecs: 1275350400000
      t3: QDateTime("2010-06-01 04:00:00.000 UTC+03:00 Qt::TimeZone UTC+03:00") msecs: 1275354000000
      

      t2 should be 00:00:00 instead of 03:00:00 (same msecs as t1 !)
      t3 should be 01:00:00 instead of 04:00:00

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            mackrol Maciej Krol
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes