From 44c930ebbac11de2ce259ce6c931cdc060c52ad0 Mon Sep 17 00:00:00 2001 From: Jamie Gadd Date: Fri, 14 Apr 2006 03:05:45 +0000 Subject: [PATCH] Fix bug in GetTimeZone where timezone wasn't set. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38702 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 2 ++ src/common/datetime.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 1a34097829..66c9f5f19c 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -64,6 +64,8 @@ All: and WXK*PAGEDOWN. If you have switch statements that use both constants from a set then you need to remove the PRIOR/NEXT versions in order to eliminate compiler errors. +- Fixed bug where wxDateTime::Now() would sometimes return an incorrect value + the first time it was called. All (GUI): diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index 5f7f6931e2..37b1864e21 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -327,7 +327,6 @@ 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 @@ -344,16 +343,17 @@ static int GetTimeZone() tm = wxLocaltime_r(&t, &tmstruct); 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 (int)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 -- 2.45.2