[Development] QDateTime::currentDateTime().toString(Qt::SystemLocaleLongDate) returns as if the DST was still in effect
Mitch Curtis
mitch.curtis at digia.com
Mon Oct 29 16:51:03 CET 2012
On Monday, October 29, 2012 04:28:17 PM Jan Kundrát wrote:
> However, `mitchc` on #qt kindly confirms that he also gets "CEST" in
> QDateTime's output, even after a reboot since the DST change. He says that
> brokenDown's tm_isdst is *not* set for him.
Mine looks like:
tm_gmtoff = 3600
tm_hour = 16
tm_isdst = 0
tm_mday = 29
tm_min = 36
tm_mon = 9
tm_sec = 9
tm_wday = 1
tm_yday = 302
tm_year = 112
tm_zone = "CET"
> So, given that `date` reports the time correctly, I suspect that Qt is using
> some strange way of obtaining the TZ information. Do you have any ideas
> about what is confusing it to believe that DST is still active on this box?
> Please note that the actual hours being displayed are always correct, it's
> just the TZ indication which is off.
The problem seems to be that localtime_r fetches the correct timezone, but the
timeZone() function in qlocale.cpp (which is used when you use a date format
like Qt::SystemLocaleLongDate) returns a hard-coded tzname[1], which is always
going to be a timezone with DST in effect:
"The array tzname contains two strings, which are the standard names of the
pair of time zones (standard and Daylight Saving) that the user has selected.
tzname[0] is the name of the standard time zone (for example, "EST"), and
tzname[1] is the name for the time zone when Daylight Saving Time is in use
(for example, "EDT"). These correspond to the std and dst strings
(respectively) from the TZ environment variable. If Daylight Saving Time is
never used, tzname[1] is the empty string. " [1]
I vaguely remember running into a similar issue with https://codereview.qt-
project.org/#change,35242, but I think it's a known issue that timezone
support in Qt is not up to scratch. John Layt is working on the ICU backend
for this stuff though [2], so it will be improved in the not-too-distant
future.
[1] http://www.gnu.org/software/libc/manual/html_node/Time-Zone-Functions.html
[2] http://www.layt.net/john/blog/odysseus/icu_did_u_c_me
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20121029/ca359e84/attachment.html>
More information about the Development
mailing list