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

Incorrect conversion of JavaScript date from C++

    XMLWordPrintable

Details

    • 948e24cb6deeaf0e55794032b90fdf20b7ef12c1

    Description

      See attached project. I'm in CET (UTC+1), so it is incorrectly assuming local time.

      QML from the project:

      import QtQuick 2.0
      import test 1.0
      
      Item {
          id: root
      
          QuickDate {
              Component.onCompleted: {
                  console.log("  actual date = " + date.toUTCString());
                  console.log("expected date = " + new Date("Thu, 01 Jan 1970 00:00:00 GMT").toUTCString());
              }
          }
      }
      

      Output:

      actual date = Wed, 31 Dec 1969 23:00:00 GMT
      expected date = Thu, 01 Jan 1970 00:00:00 GMT

      This seems to be because a QDateTime object is constructed from the QDate object using the constructor that will set the timeSpec to Qt::LocalTime.

      Attachments

        1. qml-date-bug.zip
          2 kB
          Mitch Curtis

        Issue Links

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

          Activity

            People

              Eddy Edward Welbourne
              mitch_curtis Mitch Curtis
              Votes:
              2 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes