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

QDateTime Daylight Saving wrong in CET/CEST starting 2038

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.2.0
    • 5.15.2
    • Core: Date/Time
    • None
    • Qt 5.15.2, Windows 10, Qt Creator 4.14.0
    • Windows
    • qtbase/35412acd88cad2213be966a950f3112342a299ae qtbase/b4a875544ba8f2d11e183d67f45891d6149203ed

    Description

      Local time zone is Central European Time (CET) / Central European Summer Time (CEST)

      Example:

      QDateTime dt;
      dt.setTimeSpec(Qt::LocalTime);
      QDateTime dtUtc;
      dtUtc.setTimeSpec(Qt::UTC);

      qint64 secsSince1970 = 2153407610; // 28th of March 2038 16:56:50 UTC
      dt.setSecsSinceEpoch(secsSince1970);
      dtUtc.setSecsSinceEpoch(secsSince1970);

      Result:
      dtUtc is set to 28th of March 2038 16:56:50 UTC correctly
      dt is set to 28th of March 2038 17:56:50 Local time but should be 1 hour later

      Affected time ranges:
      Sun 28 Mar 2038 01:00:00 UTC - Mon 29 Mar 2038 00:59:59 UTC - Qt at CET, actually CEST
      Mon 25 Oct 2038 01:00:00 UTC - Sun 31 Oct 2038 00:59:59 UTC - Qt at CET, actually CEST

      Sun 27 Mar 2039 01:00:00 UTC - Tue 29 Mar 2039 00:59:59 UTC - Qt at CET, actually CEST
      Tue 25 Oct 2039 01:00:00 UTC - Sun 30 Oct 2039 00:59:59 UTC - Qt at CET, actually CEST

      Sun 25 Mar 2040 01:00:00 UTC - Thu 29 Mar 2040 00:59:59 UTC - Qt at CET, actually CEST
      Thu 25 Oct 2040 01:00:00 UTC - Sun 28 Oct 2040 00:59:59 UTC - Qt at CET, actually CEST

      Fri 29 Mar 2041 01:00:00 UTC - Sun 31 Mar 2041 00:59:59 UTC - Qt at CEST, actually CET
      Fri 25 Oct 2041 01:00:00 UTC - Sun 27 Oct 2041 00:59:59 UTC - Qt at CET, actually CEST

      Sat 29 Mar 2042 01:00:00 UTC - Sun 30 Mar 2042 00:59:59 UTC - Qt at CEST, actually CET
      Sat 25 Oct 2042 01:00:00 UTC - Sun 26 Oct 2042 00:59:59 UTC - Qt at CET, actually CEST

      2043 no issue (Switchover Sun 25 Mar and Sun 25 Oct for both Qt and actually)

      Sun 27 Mar 2044 01:00:00 UTC - Tue 29 Mar 2044 00:59:59 UTC - Qt at CET, actually CEST
      Tue 25 Oct 2044 01:00:00 UTC - Sun 30 Oct 2044 00:59:59 UTC - Qt at CET, actually CEST

      And so on. It seems that after 2038 Qt always switches daylight saving time on the 29th of March and 25th of October, whereas it should be on the last Sundays of March and October.

      My suspicion is that for calculation of daylight saving time a conversion to 32 bit unix time causes an overflow somewhere.

      Attachments

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

        Activity

          People

            Eddy Edward Welbourne
            steffenfuchs steffenfuchs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes