Details
-
Suggestion
-
Resolution: Done
-
P2: Important
-
4.1.0
-
None
Description
Qt supports convering a QDateTime between local time and UTC, and to do that it obviously needs information about the current time zone.
Right now, the best way to get the current time zone is
QDateTime now = QDateTime::currentDateTime();
int timezone = now.time().hour() - now.toUTC().time().hour();
(which returns +1 if it's Winter and you are in Oslo). However, daylight saving will introduce an off-by-one error - Oslo is still in GMT+1, but the current time is adjusted.
An API that returns the actual time zone would solve that problem, and would be more elegant than the code above anyway.
Attachments
Issue Links
- relates to
-
QTBUG-23509 A mechanism for time zone handling in Qt 5.
- Closed
-
QTBUG-26161 QDateTime::toString does not output timezone
- Closed