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:
@@ -655,6 +655,18 @@ wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
|
|||||||
case wxT('z'): // time zone as [-+]HHMM
|
case wxT('z'): // time zone as [-+]HHMM
|
||||||
{
|
{
|
||||||
int ofs = tz.GetOffset();
|
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 )
|
if ( ofs < 0 )
|
||||||
{
|
{
|
||||||
res += '-';
|
res += '-';
|
||||||
|
Reference in New Issue
Block a user