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

Dates without times are wrong in QML

    XMLWordPrintable

Details

    Description

      The following unit test fails in QtQml:

      FAIL!  : tst_qqmlecmascript::assignDate(Component.onComplete JS) Compared values are not the same
         Actual   (object->dateProperty()): 1982/11/24
         Expected (QDate(1982, 11, 25)): 1982/11/25
         Loc: [/home/thiago/src/qt/qt5/qtdeclarative/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp(350)]
      

      Note that the source file for the property in question is (assignDate.qml):

              dateProperty = new Date("1982-11-25")
      

      Note that the the test above in the same file is correct, with the source (assignBasicTypes.qml):

              dateProperty = "1982-11-25"
      

      From what I can tell in the source, the latter uses QDateTime::fromString. I'm guessing the former is going through a JS Date object, which is supposed to represent a full date, time and timezone. The JS date is the locale date of "1982-11-25" (no Z, so it's locale), but it must have been interpreted as midnight Zulu time, which yields 1982-11-24T22:00-0200 localtime. When the QDate is extracted from that QDateTime, the date is wrong.

      Attachments

        Issue Links

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

          Activity

            People

              mvogt Matthew Vogt (closed Nokia identity) (Inactive)
              thiago Thiago Macieira
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes