git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43076
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
* Missing time functions and structures for use under WinCE
*/
* 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_
-struct tm * __cdecl localtime(const time_t *);
-
time_t __cdecl time(time_t *);
time_t __cdecl mktime(struct tm *);
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 *);
struct tm * __cdecl gmtime(const time_t *);
#define _tcsftime wcsftime
size_t __cdecl wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm *);
+#endif // _WX_MSW_WINCE_TIME_H_
#include <wtime.h>
#endif
#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
#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
#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
#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
#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;
}
memcpy(temp, localtime(ticks), sizeof(struct tm));
return temp;
}
+#endif // !HAVE_LOCALTIME_R
#ifndef HAVE_GMTIME_R
struct tm *wxGmtime_r(const time_t* ticks, struct tm* temp)
#ifndef HAVE_GMTIME_R
struct tm *wxGmtime_r(const time_t* ticks, struct tm* temp)
memcpy(temp, gmtime(ticks), sizeof(struct tm));
return temp;
}
memcpy(temp, gmtime(ticks), sizeof(struct tm));
return temp;
}
+#endif // !HAVE_GMTIME_R
+
+#endif // wxWinCE with VC8/other platforms
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
// macros
// Name: src/msw/wince/time.cpp
// Purpose: Implements missing time functionality for WinCE
// Author: Marco Cavallini (MCK) - wx@koansoftware.com
// Name: src/msw/wince/time.cpp
// Purpose: Implements missing time functionality for WinCE
// Author: Marco Cavallini (MCK) - wx@koansoftware.com
+// Modified by: Vadim Zeitlin for VC8 support
// Created: 31-08-2003
// RCS-ID: $Id$
// Copyright: (c) Marco Cavallini
// Created: 31-08-2003
// RCS-ID: $Id$
// Copyright: (c) Marco Cavallini
#include "wx/msw/wince/time.h"
#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 //
/////////////////////////////////////////////////////////////////////////////////////////////
// //
// strftime() - taken from OpenBSD //
/* Not needed in VS Studio 2005 */
/* Not needed in VS Studio 2005 */
-#if !(__VISUALC__ >= 1400)
size_t wcsftime(wchar_t *s,
const size_t maxsize,
const wchar_t *format,
size_t wcsftime(wchar_t *s,
const size_t maxsize,
const wchar_t *format,