When deducing the time zone from struct tm tm_gmtoff field, query tm for the
current time and not the Epoch as the DST rules -- and hence the time zone
offset -- could have changed since 1970. This is notably the case for Ireland
which used a different time zone from 1968 to 1971.
Notice that GetTimeZone() still must return the time zone without taking DST
into account, so we explicitly compensate for DST if it's in effect.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69689
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
{
// just call wxLocaltime_r() instead of figuring out whether this
// system supports tzset(), _tzset() or something else
- time_t t = 0;
+ time_t t = time(NULL);
struct tm tm;
wxLocaltime_r(&t, &tm);
// consistent results in both WX_GMTOFF_IN_TM and !WX_GMTOFF_IN_TM
// cases we have to negate it
gmtoffset = -tm.tm_gmtoff;
+
+ // this function is supposed to return the same value whether DST is
+ // enabled or not, so we need to use an additional offset if DST is on
+ // as tm_gmtoff already does include it
+ if ( tm.tm_isdst )
+ gmtoffset += 3600;
}
return (int)gmtoffset;
#elif defined(__DJGPP__) || defined(__WINE__)