]>
git.saurik.com Git - wxWidgets.git/blob - src/common/time.cpp
d3e1bd6193f8b64625f4244f74681828a0142f35
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/time.cpp
3 // Purpose: Implementation of time-related functions.
4 // Author: Vadim Zeitlin
6 // RCS-ID: $Id: wxhead.cpp,v 1.11 2010-04-22 12:44:51 zeitlin Exp $
7 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
28 #ifndef WX_GMTOFF_IN_TM
29 // Define it for some systems which don't (always) use configure but are
30 // known to have tm_gmtoff field.
31 #if defined(__WXPALMOS__) || defined(__DARWIN__)
32 #define WX_GMTOFF_IN_TM
36 // ============================================================================
38 // ============================================================================
40 // returns the time zone in the C sense, i.e. the difference UTC - local
44 #ifdef WX_GMTOFF_IN_TM
45 // set to true when the timezone is set
46 static bool s_timezoneSet
= false;
47 static long gmtoffset
= LONG_MAX
; // invalid timezone
49 // ensure that the timezone variable is set by calling wxLocaltime_r
52 // just call wxLocaltime_r() instead of figuring out whether this
53 // system supports tzset(), _tzset() or something else
54 time_t t
= time(NULL
);
57 wxLocaltime_r(&t
, &tm
);
60 // note that GMT offset is the opposite of time zone and so to return
61 // consistent results in both WX_GMTOFF_IN_TM and !WX_GMTOFF_IN_TM
62 // cases we have to negate it
63 gmtoffset
= -tm
.tm_gmtoff
;
65 // this function is supposed to return the same value whether DST is
66 // enabled or not, so we need to use an additional offset if DST is on
67 // as tm_gmtoff already does include it
71 return (int)gmtoffset
;
72 #elif defined(__DJGPP__) || defined(__WINE__)
75 return tb
.timezone
*60;
76 #elif defined(__VISUALC__)
77 // We must initialize the time zone information before using it (this will
78 // be done only once internally).
81 // Starting with VC++ 8 timezone variable is deprecated and is not even
82 // available in some standard library version so use the new function for
83 // accessing it instead.
84 #if wxCHECK_VISUALC_VERSION(8)
91 #elif defined(WX_TIMEZONE) // If WX_TIMEZONE was defined by configure, use it.
93 #elif defined(__BORLANDC__) || defined(__MINGW32__) || defined(__VISAGECPP__)
95 #elif defined(__MWERKS__)
97 #else // unknown platform -- assume it has timezone
99 #endif // WX_GMTOFF_IN_TM/!WX_GMTOFF_IN_TM