]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix formatting of the local time zone when DST is in effect.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 15 Jun 2013 21:49:05 +0000 (21:49 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 15 Jun 2013 21:49:05 +0000 (21:49 +0000)
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

index 0868f626aa24237d0bd16dc00c8dc2b431d68a60..69cc9964548f467d07e356508a2786501797f4f4 100644 (file)
@@ -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 += '-';