Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
5.5.1
-
None
Description
qDebug() << QDateTime::fromMSecsSinceEpoch(1393534800000);
prints the following on Ubuntu 14.04:
QDateTime(2014-02-28 01:00:00.000 MSK Qt::TimeSpec(LocalTime))
when the timezone is set to Moscow. This doesn't happen in other timezones I tested (Oslo, for example).
On Windows 7 it is correct, but a different timezone is chosen:
QDateTime(2014-02-28 00:00:00.000 Russia TZ 2 Standard Time Qt::TimeSpec(LocalTime))
That is with (UTC+03:00) Moscow, St. Petersburg, Volgograd (RTZ 2) set - the only available timezone in Windows for Moscow.
Take this example from Chrome's developer console:
new Date(2014, 1, 28).getTime() 1393534800000 new Date(1393534800000) Fri Feb 28 2014 00:00:00 GMT+0300 (MSK)
The problem also seems to affect C++ -> QML conversions:
#include <QApplication> #include <QtQuick> #include <QtQml> class Range : public QObject { Q_OBJECT Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged) public: QDate date() const; void setDate(const QDate &date); signals: void dateChanged(); private: QDate mDate; }; QDate Range::date() const { return mDate; } void Range::setDate(const QDate &date) { QDate adjusted = date; if (adjusted != mDate) { mDate = adjusted; qDebug() << Q_FUNC_INFO << date; qDebug() << Q_FUNC_INFO << adjusted; emit dateChanged(); } } int main(int argc, char *argv[]) { QApplication app(argc, argv); qmlRegisterType<Range>("Test", 1, 0, "Range"); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return app.exec(); } #include "main.moc"
import QtQuick 2.4 import QtQuick.Window 2.0 import Test 1.0 Window { width: 400 height: 400 visible: true Range { date: new Date(2014, 1, 28) Component.onCompleted: print(date, date.getDate(), new Date(2014, 1, 28).getDate()) } }
void Range::setDate(const QDate&) QDate("2014-02-28")
void Range::setDate(const QDate&) QDate("2014-02-28")
qml: Fri Feb 28 00:00:00 2014 GMT+0300 27 28
date.getDate() should have returned 28 there.
Attachments
Issue Links
- relates to
-
QTBUG-41726 QDateTime needs clarifications on Windows
- Closed
-
QTBUG-41422 Javascript dates are broken starting with 2014-10-26 (GMT+4 Europe/Moscow).
- Closed
-
QTBUG-42021 Incorrect calculation of next/previous transition in time zone on Windows
- Closed
-
QTBUG-46369 QDateTime::toUTC() broken under Windows for (at least) "Europe/Moscow" time zone
- Closed
-
QTBUG-45483 October 26th, 2014 is absent from QML Calendar control with "Moscow - Russia" timezone
- Closed