Commit fc6ec997 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

oleaut32: Add support for VAR_TIMEVALUEONLY and VAR_DATEVALUEONLY flags in VarDateFromUdateEx.

parent f753ff90
...@@ -1934,6 +1934,12 @@ static void test_VarDateFromUdate(void) ...@@ -1934,6 +1934,12 @@ static void test_VarDateFromUdate(void)
/* for DATE values 0.0 < x < 1.0, x and -x represent the same datetime */ /* for DATE values 0.0 < x < 1.0, x and -x represent the same datetime */
/* but when converting to DATE, prefer the positive versions */ /* 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(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, 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) ...@@ -1350,7 +1350,7 @@ INT WINAPI VariantTimeToSystemTime(double dateIn, LPSYSTEMTIME lpSt)
HRESULT WINAPI VarDateFromUdateEx(UDATE *pUdateIn, LCID lcid, ULONG dwFlags, DATE *pDateOut) HRESULT WINAPI VarDateFromUdateEx(UDATE *pUdateIn, LCID lcid, ULONG dwFlags, DATE *pDateOut)
{ {
UDATE ud; 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, 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, pUdateIn->st.wMonth, pUdateIn->st.wDay, pUdateIn->st.wYear,
...@@ -1360,6 +1360,8 @@ HRESULT WINAPI VarDateFromUdateEx(UDATE *pUdateIn, LCID lcid, ULONG dwFlags, DAT ...@@ -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)) if (lcid != MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT))
FIXME("lcid possibly not handled, treating as en-us\n"); FIXME("lcid possibly not handled, treating as en-us\n");
if (dwFlags & ~(VAR_TIMEVALUEONLY|VAR_DATEVALUEONLY))
FIXME("unsupported flags: %x\n", dwFlags);
ud = *pUdateIn; ud = *pUdateIn;
...@@ -1370,15 +1372,18 @@ HRESULT WINAPI VarDateFromUdateEx(UDATE *pUdateIn, LCID lcid, ULONG dwFlags, DAT ...@@ -1370,15 +1372,18 @@ HRESULT WINAPI VarDateFromUdateEx(UDATE *pUdateIn, LCID lcid, ULONG dwFlags, DAT
return E_INVALIDARG; return E_INVALIDARG;
/* Date */ /* 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 */ if ((dwFlags & VAR_TIMEVALUEONLY) || !(dwFlags & VAR_DATEVALUEONLY))
dateSign = (dateVal < 0.0) ? -1.0 : 1.0; {
double dateSign = (dateVal < 0.0) ? -1.0 : 1.0;
/* Time */ /* Time */
dateVal += ud.st.wHour / 24.0 * dateSign; dateVal += ud.st.wHour / 24.0 * dateSign;
dateVal += ud.st.wMinute / 1440.0 * dateSign; dateVal += ud.st.wMinute / 1440.0 * dateSign;
dateVal += ud.st.wSecond / 86400.0 * dateSign; dateVal += ud.st.wSecond / 86400.0 * dateSign;
}
TRACE("Returning %g\n", dateVal); TRACE("Returning %g\n", dateVal);
*pDateOut = dateVal; *pDateOut = dateVal;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment