oleaut32: Add support for VAR_TIMEVALUEONLY and VAR_DATEVALUEONLY flags in VarDateFromUdateEx.
This commit is contained in:
parent
f753ff90be
commit
fc6ec997e2
|
@ -1934,6 +1934,12 @@ static void test_VarDateFromUdate(void)
|
|||
/* for DATE values 0.0 < x < 1.0, x and -x represent the same datetime */
|
||||
/* but when converting to DATE, prefer the positive versions */
|
||||
UD2T(30,12,1899,6,0,0,0,6,364,0,S_OK,0.25);
|
||||
|
||||
UD2T(1,1,1980,18,1,16,0,2,1,VAR_TIMEVALUEONLY,S_OK,0.7508796296296296);
|
||||
UD2T(1,1,1980,18,1,16,0,2,1,VAR_DATEVALUEONLY,S_OK,29221.0);
|
||||
UD2T(25,12,1899,6,0,0,0,1,359,VAR_TIMEVALUEONLY,S_OK,0.25);
|
||||
UD2T(25,12,1899,6,0,0,0,1,359,VAR_DATEVALUEONLY,S_OK,-5.0);
|
||||
UD2T(1,-1,1980,18,1,16,0,0,0,VAR_TIMEVALUEONLY|VAR_DATEVALUEONLY,S_OK,0.7508796296296296);
|
||||
}
|
||||
|
||||
static void test_st2dt(int line, WORD d, WORD m, WORD y, WORD h, WORD mn,
|
||||
|
|
|
@ -1350,7 +1350,7 @@ INT WINAPI VariantTimeToSystemTime(double dateIn, LPSYSTEMTIME lpSt)
|
|||
HRESULT WINAPI VarDateFromUdateEx(UDATE *pUdateIn, LCID lcid, ULONG dwFlags, DATE *pDateOut)
|
||||
{
|
||||
UDATE ud;
|
||||
double dateVal, dateSign;
|
||||
double dateVal = 0;
|
||||
|
||||
TRACE("(%p->%d/%d/%d %d:%d:%d:%d %d %d,0x%08x,0x%08x,%p)\n", pUdateIn,
|
||||
pUdateIn->st.wMonth, pUdateIn->st.wDay, pUdateIn->st.wYear,
|
||||
|
@ -1360,6 +1360,8 @@ HRESULT WINAPI VarDateFromUdateEx(UDATE *pUdateIn, LCID lcid, ULONG dwFlags, DAT
|
|||
|
||||
if (lcid != MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT))
|
||||
FIXME("lcid possibly not handled, treating as en-us\n");
|
||||
if (dwFlags & ~(VAR_TIMEVALUEONLY|VAR_DATEVALUEONLY))
|
||||
FIXME("unsupported flags: %x\n", dwFlags);
|
||||
|
||||
ud = *pUdateIn;
|
||||
|
||||
|
@ -1370,15 +1372,18 @@ HRESULT WINAPI VarDateFromUdateEx(UDATE *pUdateIn, LCID lcid, ULONG dwFlags, DAT
|
|||
return E_INVALIDARG;
|
||||
|
||||
/* Date */
|
||||
dateVal = VARIANT_DateFromJulian(VARIANT_JulianFromDMY(ud.st.wYear, ud.st.wMonth, ud.st.wDay));
|
||||
if (!(dwFlags & VAR_TIMEVALUEONLY))
|
||||
dateVal = VARIANT_DateFromJulian(VARIANT_JulianFromDMY(ud.st.wYear, ud.st.wMonth, ud.st.wDay));
|
||||
|
||||
/* Sign */
|
||||
dateSign = (dateVal < 0.0) ? -1.0 : 1.0;
|
||||
if ((dwFlags & VAR_TIMEVALUEONLY) || !(dwFlags & VAR_DATEVALUEONLY))
|
||||
{
|
||||
double dateSign = (dateVal < 0.0) ? -1.0 : 1.0;
|
||||
|
||||
/* Time */
|
||||
dateVal += ud.st.wHour / 24.0 * dateSign;
|
||||
dateVal += ud.st.wMinute / 1440.0 * dateSign;
|
||||
dateVal += ud.st.wSecond / 86400.0 * dateSign;
|
||||
/* Time */
|
||||
dateVal += ud.st.wHour / 24.0 * dateSign;
|
||||
dateVal += ud.st.wMinute / 1440.0 * dateSign;
|
||||
dateVal += ud.st.wSecond / 86400.0 * dateSign;
|
||||
}
|
||||
|
||||
TRACE("Returning %g\n", dateVal);
|
||||
*pDateOut = dateVal;
|
||||
|
|
Loading…
Reference in New Issue