* Missing time functions and structures for use under WinCE
*/
-#ifndef __WINCE_TIME_
-#define __WINCE_TIME_
+#ifndef _WX_MSW_WINCE_TIME_H_
+#define _WX_MSW_WINCE_TIME_H_
#ifndef _TM_DEFINED
extern "C"
{
-struct tm * __cdecl localtime(const time_t *);
-
time_t __cdecl time(time_t *);
time_t __cdecl mktime(struct tm *);
+// VC8 CRT provides the other functions
+#if !defined(__VISUALC__) || (__VISUALC__ < 1400)
+
+struct tm * __cdecl localtime(const time_t *);
+
struct tm * __cdecl gmtime(const time_t *);
#define _tcsftime wcsftime
size_t __cdecl wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm *);
-}
-
extern long timezone;
+#endif // !VC8
+
+}
+
#endif // !_TM_DEFINED
-#endif // __WINCE_TIME_
+#endif // _WX_MSW_WINCE_TIME_H_
#include <wtime.h>
#endif
+// define a special symbol for VC8 instead of writing tests for 1400 repeatedly
+#ifdef __VISUALC__
+ #if __VISUALC__ >= 1400
+ #define __VISUALC8__
+ #endif
+#endif
+
#if !defined(WX_TIMEZONE) && !defined(WX_GMTOFF_IN_TM)
#if defined(__WXPALMOS__)
#define WX_GMTOFF_IN_TM
#define WX_TIMEZONE wxGetTimeZone()
#elif defined(__DARWIN__)
#define WX_GMTOFF_IN_TM
+ #elif defined(__WXWINCE__) && defined(__VISUALC8__)
+ #define WX_TIMEZONE _timezone
#else // unknown platform - try timezone
#define WX_TIMEZONE timezone
#endif
#endif // !WX_TIMEZONE && !WX_GMTOFF_IN_TM
+// NB: VC8 safe time functions could/should be used for wxMSW as well probably
+#if defined(__WXWINCE__) && defined(__VISUALC8__)
+
+struct tm *wxLocaltime_r(const time_t *t, struct tm* tm)
+{
+ __time64_t t64 = *t;
+ return _localtime64_s(tm, &t64) == 0 ? tm : NULL;
+}
+
+struct tm *wxGmtime_r(const time_t* t, struct tm* tm)
+{
+ __time64_t t64 = *t;
+ return _gmtime64_s(tm, &t64) == 0 ? tm : NULL;
+}
+
+#else // !wxWinCE with VC8
+
#if (!defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)) && wxUSE_THREADS && !defined(__WINDOWS__)
static wxMutex timeLock;
#endif
memcpy(temp, localtime(ticks), sizeof(struct tm));
return temp;
}
-#endif
+#endif // !HAVE_LOCALTIME_R
#ifndef HAVE_GMTIME_R
struct tm *wxGmtime_r(const time_t* ticks, struct tm* temp)
memcpy(temp, gmtime(ticks), sizeof(struct tm));
return temp;
}
-#endif
+#endif // !HAVE_GMTIME_R
+
+#endif // wxWinCE with VC8/other platforms
// ----------------------------------------------------------------------------
// macros
// Name: src/msw/wince/time.cpp
// Purpose: Implements missing time functionality for WinCE
// Author: Marco Cavallini (MCK) - wx@koansoftware.com
-// Modified by:
+// Modified by: Vadim Zeitlin for VC8 support
// Created: 31-08-2003
// RCS-ID: $Id$
// Copyright: (c) Marco Cavallini
#include "wx/msw/wince/time.h"
+#if defined(__VISUALC__) && (__VISUALC__ >= 1400)
+
+// VC8 does provide the time functions but not the standard ones
+#include <altcecrt.h>
+
+time_t __cdecl time(time_t *t)
+{
+ __time64_t t64;
+ if ( !_time64(&t64) )
+ return (time_t)-1;
+
+ if ( t )
+ *t = (time_t)t64;
+
+ return (time_t)t64;
+}
+
+time_t __cdecl mktime(struct tm *t)
+{
+ return (time_t)_mktime64(t);
+}
+
+#else // !VC8
+
/////////////////////////////////////////////////////////////////////////////////////////////
// //
// strftime() - taken from OpenBSD //
/* Not needed in VS Studio 2005 */
-#if !(__VISUALC__ >= 1400)
size_t wcsftime(wchar_t *s,
const size_t maxsize,
const wchar_t *format,
return sz;
}
-#endif
} /* extern "C" */
} // extern "C"
-
+#endif // VC8/!VC8