]> git.saurik.com Git - wxWidgets.git/commitdiff
Call tzset() for all compilers before using time zone variable.
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 13 Jan 2012 11:36:33 +0000 (11:36 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 13 Jan 2012 11:36:33 +0000 (11:36 +0000)
Changes of r66245 shouldn't have been specific to MSVC, we must call tzset()
when using any other compiler as well, otherwise time zone information can be
initially incorrect.

Closes #13862.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70332 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/time.cpp

index 03df19ec62b0488688fdc7e334c20126e7db612d..19568e8c592b88ac9f740b41d3e0c74e3f92214f 100644 (file)
@@ -223,15 +223,22 @@ int wxGetTimeZone()
     #else // VC++ < 8
         return timezone;
     #endif
-#elif defined(WX_TIMEZONE) // If WX_TIMEZONE was defined by configure, use it.
-    return WX_TIMEZONE;
-#elif defined(__BORLANDC__) || defined(__MINGW32__) || defined(__VISAGECPP__)
-    return _timezone;
-#elif defined(__MWERKS__)
-    return 28800;
-#else // unknown platform -- assume it has timezone
-    return timezone;
-#endif // WX_GMTOFF_IN_TM/!WX_GMTOFF_IN_TM
+#else // Use some kind of time zone variable.
+    // In any case we must initialize the time zone before using it.
+    tzset();
+
+    #if defined(WX_TIMEZONE) // If WX_TIMEZONE was defined by configure, use it.
+        return WX_TIMEZONE;
+    #elif defined(__BORLANDC__) || defined(__MINGW32__) || defined(__VISAGECPP__)
+        return _timezone;
+    #elif defined(__MWERKS__)
+        // This is just plain wrong but apparently MetroWerks runtime didn't have
+        // any way to get the time zone.
+        return 28800;
+    #else // unknown platform -- assume it has timezone
+        return timezone;
+    #endif // different time zone variables
+#endif // different ways to determine time zone
 }
 
 // Get local time as seconds since 00:00:00, Jan 1st 1970