Details
-
Bug
-
Resolution: Incomplete
-
P2: Important
-
5.13.1
Description
Refer to my SO question: https://stackoverflow.com/questions/59202237/qt-qml-qdatetime-losing-an-hour-when-coming-into-qml
#ifndef TESTOBJECT_H #define TESTOBJECT_H #include <QObject> #include <QDateTime> class TestObject : public QObject { Q_OBJECT public: TestObject(QObject* parent = nullptr) : QObject(parent) { } Q_INVOKABLE QDateTime getDateTime1() { return QDateTime(QDate(1945, 9, 28), QTime(11, 0, 0, 0), Qt::TimeSpec::UTC); } Q_INVOKABLE QDateTime getDateTime2() { return QDateTime(QDate(2011, 11, 04), QTime(11, 0, 0, 0), Qt::TimeSpec::UTC); } }; #endif // TESTOBJECT_H
Then from QML:
console.log(instance.getDateTime1()); console.log(instance.getDateTime2());
Here is the output:
qml: Fri Sep 28 06:00:00 1945 GMT-0400 qml: Fri Nov 4 07:00:00 2011 GMT-0400
Attachments
Issue Links
- depends on
-
QTBUG-80421 Use DST data even before 1970
-
- Closed
-