Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.4.1, 5.6.0
-
None
-
3379ace11b30d8e9a2c9b45789561ac44bf29c06
Description
With the following code I expect the QDateTimeEdit and the QString 's' to show "1st of January 2000 12:00:00", but it shows "1st of January 2000 11:00:00":
QDateTime t(QDate(2000, 1, 1), QTime(12, 0, 0), Qt::UTC); QDateTimeEdit edit(t); edit.setTimeSpec(Qt::UTC); QString s = edit.dateTime().toString();
My timezone is GMT+1. QDateTimeEdit::setTimeSpec() handles the QDateTime 't' as if it was a local time. But it is UTC. I consider this a bug.
The following code works as expected:
QDateTime t2(QDate(2000, 1, 1), QTime(12, 0, 0), Qt::UTC); QDateTimeEdit edit2; edit2.setTimeSpec(Qt::UTC); edit2.setDateTime(t2); QString s2 = edit2.dateTime().toString();
Attachments
For Gerrit Dashboard: QTBUG-54781 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
167030,4 | QDateTimeEdit: synchronize time-spec before initializing display | 5.6 | qt/qtbase | Status: MERGED | +2 | 0 |