// so long as the above copyright and this permission statement
// are retained in all copies.
//
-// Licence: wxWindows license
+// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
/*
#include "wx/datetime.h"
#include "wx/timer.h" // for wxGetLocalTimeMillis()
+const long wxDateTime::TIME_T_FACTOR = 1000l;
+
// ----------------------------------------------------------------------------
// conditional compilation
// ----------------------------------------------------------------------------
#undef HAVE_STRPTIME
#endif // broken strptime()
+#if defined(__MWERKS__) && wxUSE_UNICODE
+ #include <wtime.h>
+#endif
+
#if !defined(WX_TIMEZONE) && !defined(WX_GMTOFF_IN_TM)
#if defined(__BORLANDC__) || defined(__MINGW32__) || defined(__VISAGECPP__)
#define WX_TIMEZONE _timezone
return daysInMonth[wxDateTime::IsLeapYear(year)][month];
}
-// ensure that the timezone variable is set by calling localtime
+// returns the time zone in the C sense, i.e. the difference UTC - local
+// (in seconds)
static int GetTimeZone()
{
// set to TRUE when the timezone is set
#ifdef WX_GMTOFF_IN_TM
static long gmtoffset = LONG_MAX; // invalid timezone
#endif
-
+
wxCRIT_SECT_LOCKER(lock, gs_critsectTimezone);
+ // ensure that the timezone variable is set by calling localtime
if ( !s_timezoneSet )
{
// just call localtime() instead of figuring out whether this system
// supports tzset(), _tzset() or something else
- time_t t = 0;
+ time_t t = 0;
struct tm *tm;
tm = localtime(&t);
s_timezoneSet = TRUE;
+
#ifdef WX_GMTOFF_IN_TM
- gmtoffset = tm->tm_gmtoff;
+ // 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;
#endif
}
// tokenize the string
size_t nPosCur = 0;
- static const wxChar *dateDelimiters = _T(".,/-\t\n ");
+ static const wxChar *dateDelimiters = _T(".,/-\t\r\n ");
wxStringTokenizer tok(p, dateDelimiters);
while ( tok.HasMoreTokens() )
{