From 809003a148b6d1451dc13d0e786718ccd3d3d91e Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 24 Sep 2009 19:12:10 +0000 Subject: [PATCH] Applied #9668: made wxGetTimeStatic() dynamic git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@62096 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/common/datetime.cpp | 21 ++++++++------------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index f95bc1504b..1f6a55640d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -110,6 +110,7 @@ All: wxDC::SetDeviceClippingRegion(), wxShowEvent::IsShown(), wxIconizeEvent::IsIconized(), wxFileName::StripExtension(), wxXmlNode::GetAttribute[s](), wxXmlNode::AddAttribute(). +- wxDateTime timezone functions now dynamic (no caching). All (GUI): diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index f3ab89c64c..a9329be44a 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -150,14 +150,10 @@ wxCUSTOM_TYPE_INFO(wxDateTime, wxToStringConverter , wxFromStringCon #elif defined(__WXMSW__) static long wxGetTimeZone() { - static long s_timezone = MAXLONG; // invalid timezone - if (s_timezone == MAXLONG) - { - TIME_ZONE_INFORMATION info; - GetTimeZoneInformation(&info); - s_timezone = info.Bias * 60; // convert minutes to seconds - } - return s_timezone; + TIME_ZONE_INFORMATION info; + GetTimeZoneInformation(&info); + long timeZone = info.Bias * 60; // convert minutes to seconds + return timeZone; } #define WX_TIMEZONE wxGetTimeZone() #elif defined(__VISAGECPP__) @@ -375,6 +371,7 @@ wxDateTime::wxDateTime_t GetNumOfDaysInMonth(int year, wxDateTime::Month month) // (in seconds) static int GetTimeZone() { +#ifdef WX_GMTOFF_IN_TM // set to true when the timezone is set static bool s_timezoneSet = false; static long gmtoffset = LONG_MAX; // invalid timezone @@ -390,17 +387,15 @@ static int GetTimeZone() wxLocaltime_r(&t, &tm); s_timezoneSet = true; -#ifdef WX_GMTOFF_IN_TM // note that GMT offset is the opposite of time zone and so to return // consistent results in both WX_GMTOFF_IN_TM and !WX_GMTOFF_IN_TM // cases we have to negate it gmtoffset = -tm.tm_gmtoff; -#else // !WX_GMTOFF_IN_TM - gmtoffset = WX_TIMEZONE; -#endif // WX_GMTOFF_IN_TM/!WX_GMTOFF_IN_TM } - return (int)gmtoffset; +#else // !WX_GMTOFF_IN_TM + return WX_TIMEZONE; +#endif // WX_GMTOFF_IN_TM/!WX_GMTOFF_IN_TM } // return the integral part of the JDN for the midnight of the given date (to