webservices: Implement WsFileTimeToDateTime.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2bcff80cda
commit
49799912c5
|
@ -2044,6 +2044,26 @@ HRESULT WINAPI WsDateTimeToFileTime( const WS_DATETIME *dt, FILETIME *ft, WS_ERR
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* WsFileTimeToDateTime [webservices.@]
|
||||
*/
|
||||
HRESULT WINAPI WsFileTimeToDateTime( const FILETIME *ft, WS_DATETIME *dt, WS_ERROR *error )
|
||||
{
|
||||
unsigned __int64 ticks;
|
||||
|
||||
TRACE( "%p %p %p\n", ft, dt, error );
|
||||
if (error) FIXME( "ignoring error parameter\n" );
|
||||
|
||||
if (!dt || !ft) return E_INVALIDARG;
|
||||
|
||||
ticks = ((unsigned __int64)ft->dwHighDateTime << 32) | ft->dwLowDateTime;
|
||||
if (ticks > MAX_UINT64 - TICKS_1601_01_01) return WS_E_NUMERIC_OVERFLOW;
|
||||
if (ticks + TICKS_1601_01_01 > TICKS_MAX) return WS_E_INVALID_FORMAT;
|
||||
dt->ticks = ticks + TICKS_1601_01_01;
|
||||
dt->format = WS_DATETIME_FORMAT_UTC;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT read_get_node_text( struct reader *reader, WS_XML_UTF8_TEXT **ret )
|
||||
{
|
||||
WS_XML_TEXT_NODE *text;
|
||||
|
|
|
@ -3056,6 +3056,50 @@ static void test_WsDateTimeToFileTime(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void test_WsFileTimeToDateTime(void)
|
||||
{
|
||||
WS_DATETIME dt;
|
||||
FILETIME ft;
|
||||
HRESULT hr;
|
||||
|
||||
hr = WsFileTimeToDateTime( NULL, NULL, NULL );
|
||||
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
||||
|
||||
ft.dwLowDateTime = ft.dwHighDateTime = 0;
|
||||
hr = WsFileTimeToDateTime( &ft, NULL, NULL );
|
||||
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
||||
|
||||
hr = WsFileTimeToDateTime( NULL, &dt, NULL );
|
||||
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
||||
|
||||
dt.ticks = 0xdeadbeef;
|
||||
dt.format = 0xdeadbeef;
|
||||
hr = WsFileTimeToDateTime( &ft, &dt, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
ok( dt.ticks == 0x701ce1722770000, "got %x%08x\n", (ULONG)(dt.ticks >> 32), (ULONG)dt.ticks );
|
||||
ok( dt.format == WS_DATETIME_FORMAT_UTC, "got %u\n", dt.format );
|
||||
|
||||
ft.dwLowDateTime = 0xd1c03fff;
|
||||
ft.dwHighDateTime = 0x24c85a5e;
|
||||
hr = WsFileTimeToDateTime( &ft, &dt, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
ok( dt.ticks == 0x2bca2875f4373fff, "got %x%08x\n", (ULONG)(dt.ticks >> 32), (ULONG)dt.ticks );
|
||||
ok( dt.format == WS_DATETIME_FORMAT_UTC, "got %u\n", dt.format );
|
||||
|
||||
ft.dwLowDateTime++;
|
||||
hr = WsFileTimeToDateTime( &ft, &dt, NULL );
|
||||
ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr );
|
||||
|
||||
ft.dwLowDateTime = 0xdd88ffff;
|
||||
ft.dwHighDateTime = 0xf8fe31e8;
|
||||
hr = WsFileTimeToDateTime( &ft, &dt, NULL );
|
||||
ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr );
|
||||
|
||||
ft.dwLowDateTime++;
|
||||
hr = WsFileTimeToDateTime( &ft, &dt, NULL );
|
||||
ok( hr == WS_E_NUMERIC_OVERFLOW, "got %08x\n", hr );
|
||||
}
|
||||
|
||||
START_TEST(reader)
|
||||
{
|
||||
test_WsCreateError();
|
||||
|
@ -3083,4 +3127,5 @@ START_TEST(reader)
|
|||
test_WsResetHeap();
|
||||
test_datetime();
|
||||
test_WsDateTimeToFileTime();
|
||||
test_WsFileTimeToDateTime();
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
@ stub WsEncodeUrl
|
||||
@ stub WsEndReaderCanonicalization
|
||||
@ stub WsEndWriterCanonicalization
|
||||
@ stub WsFileTimeToDateTime
|
||||
@ stdcall WsFileTimeToDateTime(ptr ptr ptr)
|
||||
@ stub WsFillBody
|
||||
@ stdcall WsFillReader(ptr long ptr ptr)
|
||||
@ stdcall WsFindAttribute(ptr ptr ptr long ptr ptr)
|
||||
|
|
Loading…
Reference in New Issue