Use VariantTimeToSystemTime() in wxConvertOleToVariant().
Fix the problem with variants containing only time (but not date) information. Also check in the symmetric changes to wxConvertVariantToOle() but disable them for now as they were not tested. Closes #11177. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@61846 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -606,11 +606,31 @@ WXDLLEXPORT bool wxConvertVariantToOle(const wxVariant& variant, VARIANTARG& ole
|
|||||||
wxDateTime date( variant.GetDateTime() );
|
wxDateTime date( variant.GetDateTime() );
|
||||||
oleVariant.vt = VT_DATE;
|
oleVariant.vt = VT_DATE;
|
||||||
|
|
||||||
|
// we ought to use SystemTimeToVariantTime() here but this code is
|
||||||
|
// untested and hence currently disabled, please let us know if it
|
||||||
|
// works for you and we'll enable it
|
||||||
|
#if 0
|
||||||
|
const wxDateTime::Tm tm(date.GetTm());
|
||||||
|
|
||||||
|
SYSTEMTIME st;
|
||||||
|
st.wYear = (WXWORD)tm.year;
|
||||||
|
st.wMonth = (WXWORD)(tm.mon - wxDateTime::Jan + 1);
|
||||||
|
st.wDay = tm.mday;
|
||||||
|
|
||||||
|
st.wDayOfWeek = 0;
|
||||||
|
st.wHour = tm.hour;
|
||||||
|
st.wMinute = tm.min;
|
||||||
|
st.wSecond = tm.sec;
|
||||||
|
st.wMilliseconds = tm.msec;
|
||||||
|
|
||||||
|
SystemTimeToVariantTime(&st, &oleVariant.date);
|
||||||
|
#else
|
||||||
long dosDateTime = date.GetAsDOS();
|
long dosDateTime = date.GetAsDOS();
|
||||||
short dosDate = short((dosDateTime & 0xFFFF0000) >> 16);
|
short dosDate = short((dosDateTime & 0xFFFF0000) >> 16);
|
||||||
short dosTime = short(dosDateTime & 0xFFFF);
|
short dosTime = short(dosDateTime & 0xFFFF);
|
||||||
|
|
||||||
DosDateTimeToVariantTime(dosDate, dosTime, & oleVariant.date);
|
DosDateTimeToVariantTime(dosDate, dosTime, & oleVariant.date);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if (type == wxT("void*"))
|
else if (type == wxT("void*"))
|
||||||
@@ -689,14 +709,17 @@ WXDLLEXPORT bool wxConvertOleToVariant(const VARIANTARG& oleVariant, wxVariant&
|
|||||||
case VT_DATE:
|
case VT_DATE:
|
||||||
{
|
{
|
||||||
#if wxUSE_DATETIME
|
#if wxUSE_DATETIME
|
||||||
unsigned short dosDate = 0;
|
SYSTEMTIME st;
|
||||||
unsigned short dosTime = 0;
|
VariantTimeToSystemTime(oleVariant.date, &st);
|
||||||
VariantTimeToDosDateTime(oleVariant.date, & dosDate, & dosTime);
|
|
||||||
|
|
||||||
long dosDateTime = (dosDate << 16) | dosTime;
|
|
||||||
wxDateTime date;
|
wxDateTime date;
|
||||||
date.SetFromDOS(dosDateTime);
|
|
||||||
variant = date;
|
variant = date;
|
||||||
|
date.Set(st.wDay,
|
||||||
|
(wxDateTime::Month)(wxDateTime::Jan + st.wMonth - 1),
|
||||||
|
st.wYear,
|
||||||
|
st.wHour,
|
||||||
|
st.wMinute,
|
||||||
|
st.wSecond);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user