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