Don't add DST offset when converting to local time zone.
Local time zone already logically includes DST, even if its offset doesn't account for it (because the offset depends on the date, so it can't be part of TZ itself), so don't add it again when converting to/from it. Closes #16585. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77899 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
445e2c32e2
commit
aaddf6be7f
@ -2066,9 +2066,15 @@ wxDateTime& wxDateTime::MakeTimezone(const TimeZone& tz, bool noDST)
|
||||
{
|
||||
long secDiff = wxGetTimeZone() + tz.GetOffset();
|
||||
|
||||
// we need to know whether DST is or not in effect for this date unless
|
||||
// the test disabled by the caller
|
||||
if ( !noDST && (IsDST() == 1) )
|
||||
// We are converting from the local time, but local time zone does not
|
||||
// include the DST offset (as it varies depending on the date), so we have
|
||||
// to handle DST manually, unless a special flag inhibiting this was
|
||||
// specified.
|
||||
//
|
||||
// Notice that we also shouldn't add the DST offset if we're already in the
|
||||
// local time zone, as indicated by offset of 0, converting from local time
|
||||
// to local time zone shouldn't change it, whether DST is in effect or not.
|
||||
if ( !noDST && secDiff && (IsDST() == 1) )
|
||||
{
|
||||
// FIXME we assume that the DST is always shifted by 1 hour
|
||||
secDiff -= 3600;
|
||||
@ -2081,9 +2087,8 @@ wxDateTime& wxDateTime::MakeFromTimezone(const TimeZone& tz, bool noDST)
|
||||
{
|
||||
long secDiff = wxGetTimeZone() + tz.GetOffset();
|
||||
|
||||
// we need to know whether DST is or not in effect for this date unless
|
||||
// the test disabled by the caller
|
||||
if ( !noDST && (IsDST() == 1) )
|
||||
// See comment in MakeTimezone() above, the logic here is exactly the same.
|
||||
if ( !noDST && secDiff && (IsDST() == 1) )
|
||||
{
|
||||
// FIXME we assume that the DST is always shifted by 1 hour
|
||||
secDiff -= 3600;
|
||||
|
Loading…
Reference in New Issue
Block a user