Use wxDateTime

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19843 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 2003-03-28 09:15:01 +00:00
parent 5175dbbd9f
commit 61bfe4b0ca

View File

@ -54,7 +54,9 @@
static int rgMonthDays[13] = static int rgMonthDays[13] =
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}; {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, static BOOL OleDateFromTm(WORD wYear, WORD wMonth, WORD wDay,
WORD wHour, WORD wMinute, WORD wSecond, DATE& dtDest); WORD wHour, WORD wMinute, WORD wSecond, DATE& dtDest);
static BOOL TmFromOleDate(DATE dtSrc, struct tm& tmDest); static BOOL TmFromOleDate(DATE dtSrc, struct tm& tmDest);
@ -600,7 +602,8 @@ bool wxConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant)
oleVariant.bstrVal = wxConvertStringToOle(str); oleVariant.bstrVal = wxConvertStringToOle(str);
} }
// For some reason, Watcom C++ can't link variant.cpp with time/date classes compiled // 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")) else if (type == wxT("date"))
{ {
wxDate date( variant.GetDate() ); wxDate date( variant.GetDate() );
@ -619,6 +622,17 @@ bool wxConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant)
time.GetHour(), time.GetMinute(), time.GetSecond(), oleVariant.date)) time.GetHour(), time.GetMinute(), time.GetSecond(), oleVariant.date))
return FALSE; 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 #endif
else if (type == wxT("void*")) else if (type == wxT("void*"))
{ {
@ -695,15 +709,14 @@ bool wxConvertOleToVariant(const VARIANTARG& oleVariant, wxVariant& variant)
} }
case VT_DATE: case VT_DATE:
{ {
#if wxUSE_TIMEDATE #if wxUSE_DATETIME
struct tm tmTemp; struct tm tmTemp;
if (!TmFromOleDate(oleVariant.date, tmTemp)) if (!TmFromOleDate(oleVariant.date, tmTemp))
return FALSE; return FALSE;
wxDate date(tmTemp.tm_yday, tmTemp.tm_mon, tmTemp.tm_year); wxDateTime date(tmTemp.tm_yday, (wxDateTime::Month) tmTemp.tm_mon, tmTemp.tm_year, tmTemp.tm_hour, tmTemp.tm_min, tmTemp.tm_sec);
wxTime time(date, tmTemp.tm_hour, tmTemp.tm_min, tmTemp.tm_sec);
variant = time; variant = date;
#endif #endif
break; break;