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

[REGR: 5.15.9 -> 5.15.10] QDateTime::addDays() gives wrong result in Qt 5.15.10

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.15.11
    • 5.15.10
    • Core: Date/Time
    • None
    • All
    • a567d14c0f (qt/tqtc-qtbase/5.15)

    Description

      The behavior of QDateTime::addDays() has changed between 5.15.8 and 5.15.10 when a DST change happens in the days that are added. Using this test program:

      #include <QTimeZone>
      #include <QDateTime>
      #include <QDebug>
      
      int main(int argc, char *argv[])
      {
        QDateTime dt = QDateTime::fromSecsSinceEpoch(1143325800, Qt::LocalTime);
        QDateTime plusOne = dt.addDays(1);
      
        qDebug() << QT_VERSION_STR << QTimeZone::systemTimeZone();
        qDebug() << dt << dt.toUTC();
        qDebug() << plusOne << plusOne.toUTC();
        qDebug() << dt.secsTo(plusOne) << dt.daysTo(plusOne);
      }
      

      the value of plusOne is different for Qt 5.15.8 and 5.15.10 (note the time zone):

      5.15.8 QTimeZone("Europe/Vienna")
      QDateTime(2006-03-25 23:30:00.000 W. Europe Standard Time Qt::LocalTime) QDateTime(2006-03-25 22:30:00.000 UTC Qt::UTC)
      QDateTime(2006-03-26 23:30:00.000 W. Europe Daylight Time Qt::LocalTime) QDateTime(2006-03-26 21:30:00.000 UTC Qt::UTC)
      82800 1
      
      15.15.10 QTimeZone("Europe/Vienna")
      QDateTime(2006-03-25 23:30:00.000 W. Europe Standard Time Qt::LocalTime) QDateTime(2006-03-25 22:30:00.000 UTC Qt::UTC)
      QDateTime(2006-03-27 00:30:00.000 W. Europe Daylight Time Qt::LocalTime) QDateTime(2006-03-26 22:30:00.000 UTC Qt::UTC)
      86400 2
      
       

      This is probably related to https://bugreports.qt.io/browse/QTBUG-102109

      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
              juergen.steiner Jürgen Steiner
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes