]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix bug in GetTimeZone where timezone wasn't set.
authorJamie Gadd <jrgadd2@cs.latrobe.edu.au>
Fri, 14 Apr 2006 03:05:45 +0000 (03:05 +0000)
committerJamie Gadd <jrgadd2@cs.latrobe.edu.au>
Fri, 14 Apr 2006 03:05:45 +0000 (03:05 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38702 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
src/common/datetime.cpp

index 1a340978294695e0fe2386bb3fecfa6f9c3bca19..66c9f5f19c84dcecdc2ca7e6f94a2333c98d84ae 100644 (file)
@@ -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):
index 5f7f6931e296a30a0c903ea0d4822c5c6a1ec3cb..37b1864e219a211df9edc6f3f08ee02385ce0e7d 100644 (file)
@@ -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