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

Timezone information is not fully updated after changing timezone

    XMLWordPrintable

Details

    Description

      QDateTime does not always provide the timezone information correctly when the time zone is changed by user while the application is running on Windows.

      Example code which demonstrates the problem (full example code attached):

          QDateTime localnow = QDateTime::currentDateTime();
          localnow.setOffsetFromUtc(localnow.offsetFromUtc());
          localnow.toString(Qt::ISODate);
          localnow.setTimeSpec(Qt::LocalTime);
      
          // CHANGE time zone while the for loop is running
          for (int i = 0; i < 15000; i++)
          {
              qDebug() << "Timezone: " << localnow.timeZone();
              qDebug() << "Date:     " << localnow;
      
              qDebug() << "" ;
          }
      

      QtCreators application output shows the change on the timezone only when timezone() called:

      Timezone: QTimeZone("America/Santa_Isabel")
      Date: QDateTime(2015-10-01 03:33:09.782 Pacific Daylight Time (Mexico) Qt::TimeSpec(LocalTime))

      Timezone: QTimeZone("Pacific/Guadalcanal")
      Date: QDateTime(2015-10-01 03:33:09.782 Pacific Daylight Time (Mexico) Qt::TimeSpec(LocalTime))

      When the application is started again also the localnow1; has the updated timezone:

      Timezone: QTimeZone("Pacific/Guadalcanal")
      Date: QDateTime(2015-10-01 21:35:31.765 Central Pacific Standard Time Qt::TimeSpec(LocalTime))

      Attachments

        1. example.zip
          2 kB
          Tarja Sundqvist

        Issue Links

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

          Activity

            People

              Eddy Edward Welbourne
              tarjasundqvist Tarja Sundqvist
              Votes:
              4 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes