From 33e6d385a5b1454245e08093b78219c789c639cc Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 15 Jun 2013 21:49:05 +0000 Subject: [PATCH] Fix formatting of the local time zone when DST is in effect. We must add DST offset manually as wxGetTimeZone() doesn't take DST into account. This fixes the handling of "%z" in format strings. Closes #15250. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74242 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/datetimefmt.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/common/datetimefmt.cpp b/src/common/datetimefmt.cpp index 0868f626aa..69cc996454 100644 --- a/src/common/datetimefmt.cpp +++ b/src/common/datetimefmt.cpp @@ -655,6 +655,18 @@ wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const case wxT('z'): // time zone as [-+]HHMM { int ofs = tz.GetOffset(); + + // The time zone offset does not include the DST, but + // we do need to take it into account when showing the + // time in the local time zone to the user. + if ( ofs == -wxGetTimeZone() && IsDST() == 1 ) + { + // FIXME: As elsewhere in wxDateTime, we assume + // that the DST is always 1 hour, but this is not + // true in general. + ofs += 3600; + } + if ( ofs < 0 ) { res += '-'; -- 2.47.2