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

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 5.15.10
    • Fix Version/s: 5.15.11
    • Component/s: Core: Date/Time
    • Labels:
      None
    • Platform/s:
      All
    • Commits:
      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

          For Gerrit Dashboard: QTBUG-105064
          # Subject Branch Project Status CR V

            Activity

              People

              Assignee:
              Eddy Edward Welbourne
              Reporter:
              juergen.steiner Jürgen Steiner
              PM Owner:
              Vladimir Minenko Vladimir Minenko
              RnD Owner:
              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