Details
-
Suggestion
-
Resolution: Done
-
P4: Low
-
4.8.3
-
None
-
openSUSE Linux 12.2 with custom built Qt 4.8.3 i586
Description
Look at this example:
#include <QCoreApplication> #include <QDateTime> #include <QDebug> int main(int argc, char * argv[]) { QDateTime dt; dt = QDateTime::fromString("2013-01-01T12:00:00-0600", Qt::ISODate); qDebug() << dt << dt.toUTC() << dt.toLocalTime() << dt.toUTC().toLocalTime(); dt = QDateTime::fromString("2013-01-01T12:00:00-0400", Qt::ISODate); qDebug() << dt << dt.toUTC() << dt.toLocalTime() << dt.toUTC().toLocalTime(); return 0; }
This will output (in timezone UTC+1 and C locale):
QDateTime("Tue Jan 1 12:00:00 2013") QDateTime("Tue Jan 1 18:00:00 2013") QDateTime("Tue Jan 1 12:00:00 2013") QDateTime("Tue Jan 1 19:00:00 2013") QDateTime("Tue Jan 1 12:00:00 2013") QDateTime("Tue Jan 1 16:00:00 2013") QDateTime("Tue Jan 1 12:00:00 2013") QDateTime("Tue Jan 1 17:00:00 2013")
Notice how the third column (result of toLocalTime()) always returns the original hour values irrespective of the original timezone while the fourth column (result of toUTC().toLocalTime()) actually shows the correct local time.
I think, at least QDateTime::toTimeSpec() and QDateTimePrivate::getLocal() need to be fixed.
Attachments
Issue Links
- relates to
-
QTBUG-26161 QDateTime::toString does not output timezone
-
- Closed
-