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
This commit is contained in:
Vadim Zeitlin
2013-06-15 21:49:05 +00:00
parent 68d5ce9099
commit 33e6d385a5

View 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 += '-';