// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "automtn.h"
#endif
#define _FORCENAMELESSUNION
#include "wx/log.h"
+#include "wx/msw/private.h"
#include "wx/msw/ole/oleutils.h"
#include "wx/msw/ole/automtn.h"
-#include "wx/msw/private.h"
#include <math.h>
+
+#ifdef __WXWINCE__
+#include "wx/msw/wince/time.h"
+#else
#include <time.h>
+#endif
#include <wtypes.h>
#include <unknwn.h>
+
#include <ole2.h>
#define _huge
+
+#ifndef __WXWINCE__
#include <ole2ver.h>
+#endif
+
#include <oleauto.h>
// Verifies will fail if the needed buffer size is too large
static int rgMonthDays[13] =
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};
-#if wxUSE_TIMEDATE
+#if wxUSE_DATETIME
+#include "wx/datetime.h"
+
static BOOL OleDateFromTm(WORD wYear, WORD wMonth, WORD wDay,
WORD wHour, WORD wMinute, WORD wSecond, DATE& dtDest);
static BOOL TmFromOleDate(DATE dtSrc, struct tm& tmDest);
oleVariant.bstrVal = wxConvertStringToOle(str);
}
// For some reason, Watcom C++ can't link variant.cpp with time/date classes compiled
-#if wxUSE_TIMEDATE && !defined(__WATCOMC__)
+// Now obsolete
+#if 0 // wxUSE_TIMEDATE && !defined(__WATCOMC__)
else if (type == wxT("date"))
{
wxDate date( variant.GetDate() );
time.GetHour(), time.GetMinute(), time.GetSecond(), oleVariant.date))
return FALSE;
}
+#endif
+#if wxUSE_DATETIME
+ else if (type == wxT("datetime"))
+ {
+ wxDateTime date( variant.GetDateTime() );
+ oleVariant.vt = VT_DATE;
+
+ if (!OleDateFromTm(date.GetYear(), date.GetMonth(), date.GetDay(),
+ date.GetHour(), date.GetMinute(), date.GetSecond(), oleVariant.date))
+ return FALSE;
+ }
#endif
else if (type == wxT("void*"))
{
}
case VT_DATE:
{
-#if wxUSE_TIMEDATE
+#if wxUSE_DATETIME
struct tm tmTemp;
if (!TmFromOleDate(oleVariant.date, tmTemp))
return FALSE;
- wxDate date(tmTemp.tm_yday, tmTemp.tm_mon, tmTemp.tm_year);
- wxTime time(date, tmTemp.tm_hour, tmTemp.tm_min, tmTemp.tm_sec);
+ wxDateTime date(tmTemp.tm_yday, (wxDateTime::Month) tmTemp.tm_mon, tmTemp.tm_year, tmTemp.tm_hour, tmTemp.tm_min, tmTemp.tm_sec);
- variant = time;
+ variant = date;
#endif
break;
if (dtSrc > MAX_DATE || dtSrc < MIN_DATE) // about year 100 to about 9999
return FALSE;
- long nDays; // Number of days since Dec. 30, 1899
long nDaysAbsolute; // Number of days since 1/1/0
long nSecsInDay; // Time in seconds since midnight
long nMinutesInDay; // Minutes in day
double dblDate = dtSrc; // tempory serial date
- // If a valid date, then this conversion should not overflow
- nDays = (long)dblDate;
-
// Round to the second
dblDate += ((dtSrc > 0.0) ? HALF_SECOND : -HALF_SECOND);
// Month number always >= n/32, so save some loop time */
for (tmDest.tm_mon = (n4Day >> 5) + 1;
- n4Day > rgMonthDays[tmDest.tm_mon]; tmDest.tm_mon++);
+ n4Day > rgMonthDays[tmDest.tm_mon]; tmDest.tm_mon++)
+ ;
tmDest.tm_mday = (int)(n4Day - rgMonthDays[tmDest.tm_mon-1]);