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

QDateTime::toUTC() broken under Windows for (at least) "Europe/Moscow" time zone

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3: Somewhat important
    • None
    • 5.4.1, 5.4.2
    • Core: Date/Time
    • None
    • Qt 5.4.1, Windows 8 64bit, MinGW 32bit, MSVC2013 32bit, MSVC2013 64bit

    Description

      Here is sample code for a bug reproduction:

      #include <QCoreApplication>
      #include <QDateTime>
      #include <QTimeZone>
      
      #include <iostream>
      
      static void printQdt(const QDateTime &qdt)
      {
          std::cout << qdt.toString("yyyy-MM-dd HH-mm-ss.zzz t").toStdString()
                    << ", offsetFromUtc: "
                    << qdt.offsetFromUtc()
                    << std::endl;
      }
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
          QDateTime point(QDate(2015, 5, 27),
                          QTime(16, 37, 00),
                          QTimeZone("Europe/Moscow"));
      
          printQdt(point);
          printQdt(point.toUTC());
      
          return a.exec();
      }
      

      In a GNU/Linux environment output is following (i.e. a datetime representation converted to UTC as expected):

      2015-05-27 16-37-00.000 MSK, offsetFromUtc: 10800
      2015-05-27 13-37-00.000 UTC, offsetFromUtc: 0
      

      In a Windows 8 environment output is following (i.e. UTC conversion failed, although time zone itself looks correct):

      2015-05-27 16-37-00.000 RTZ 2 (winter), offsetFromUtc: 0
      2015-05-27 16-37-00.000 UTC, offsetFromUtc: 0
      

      Once you change time to another one (for example, "Europe/Paris") then it works as expected in both cases.

      Attachments

        Issue Links

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

          Activity

            People

              thiago Thiago Macieira
              i.bereznyak Igor Bereznyak
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes