From: Jeff Smith whydoubt@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54683 --- dlls/shlwapi/tests/ordinal.c | 44 +++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 11 deletions(-)
diff --git a/dlls/shlwapi/tests/ordinal.c b/dlls/shlwapi/tests/ordinal.c index 7cb997c304c..1f3c8e28512 100644 --- a/dlls/shlwapi/tests/ordinal.c +++ b/dlls/shlwapi/tests/ordinal.c @@ -1669,13 +1669,22 @@ static void test_SHSetWindowBits(void) static void test_SHFormatDateTimeA(const SYSTEMTIME *st) { FILETIME UNALIGNED filetime; + FILETIME UNALIGNED filetimeCheck; + SYSTEMTIME universalSystemTime; CHAR buff[100], buff2[100], buff3[100]; + BOOL dstMatch; DWORD flags; INT ret;
- SystemTimeToFileTime(st, &filetime); /* SHFormatDateTime expects input as utc */ - LocalFileTimeToFileTime(&filetime, &filetime); + TzSpecificLocalTimeToSystemTime(NULL, st, &universalSystemTime); + SystemTimeToFileTime(&universalSystemTime, &filetime); + + /* SHFormatDateTime used to handle DST in a different manner */ + SystemTimeToFileTime(st, &filetimeCheck); + LocalFileTimeToFileTime(&filetimeCheck, &filetimeCheck); + dstMatch = (filetime.dwHighDateTime == filetimeCheck.dwHighDateTime) && + (filetime.dwLowDateTime == filetimeCheck.dwLowDateTime);
/* no way to get required buffer length here */ ret = pSHFormatDateTimeA(&filetime, NULL, NULL, 0); @@ -1731,14 +1740,18 @@ static void test_SHFormatDateTimeA(const SYSTEMTIME *st) ok(ret == lstrlenA(buff)+1, "got %d\n", ret); ret = GetTimeFormatA(LOCALE_USER_DEFAULT, TIME_NOSECONDS | LOCALE_USE_CP_ACP, st, NULL, buff2, sizeof(buff2)); ok(ret == lstrlenA(buff2)+1, "got %d\n", ret); - ok(lstrcmpA(buff, buff2) == 0, "expected (%s), got (%s)\n", buff2, buff); + todo_wine_if(!dstMatch) + ok(lstrcmpA(buff, buff2) == 0 || broken(!dstMatch) /* pre Windows 7 */, + "expected (%s), got (%s)\n", buff2, buff);
flags = FDTF_NOAUTOREADINGORDER | FDTF_LONGTIME; ret = pSHFormatDateTimeA(&filetime, &flags, buff, sizeof(buff)); ok(ret == lstrlenA(buff)+1, "got %d\n", ret); ret = GetTimeFormatA(LOCALE_USER_DEFAULT, LOCALE_USE_CP_ACP, st, NULL, buff2, sizeof(buff2)); ok(ret == lstrlenA(buff2)+1, "got %d\n", ret); - ok(lstrcmpA(buff, buff2) == 0, "expected (%s), got (%s)\n", buff2, buff); + todo_wine_if(!dstMatch) + ok(lstrcmpA(buff, buff2) == 0 || broken(!dstMatch) /* pre Windows 7 */, + "expected (%s), got (%s)\n", buff2, buff);
/* both time flags */ flags = FDTF_NOAUTOREADINGORDER | FDTF_LONGTIME | FDTF_SHORTTIME; @@ -1746,7 +1759,9 @@ static void test_SHFormatDateTimeA(const SYSTEMTIME *st) ok(ret == lstrlenA(buff)+1, "got %d\n", ret); ret = GetTimeFormatA(LOCALE_USER_DEFAULT, LOCALE_USE_CP_ACP, st, NULL, buff2, sizeof(buff2)); ok(ret == lstrlenA(buff2)+1, "got %d\n", ret); - ok(lstrcmpA(buff, buff2) == 0, "expected (%s), got (%s)\n", buff2, buff); + todo_wine_if(!dstMatch) + ok(lstrcmpA(buff, buff2) == 0 || broken(!dstMatch) /* pre Windows 7 */, + "expected (%s), got (%s)\n", buff2, buff);
flags = FDTF_NOAUTOREADINGORDER | FDTF_SHORTDATE; ret = pSHFormatDateTimeA(&filetime, &flags, buff, sizeof(buff)); @@ -1776,7 +1791,8 @@ static void test_SHFormatDateTimeA(const SYSTEMTIME *st) ok(ret == lstrlenA(buff)+1, "got %d, length %d\n", ret, lstrlenA(buff)+1); ret = GetTimeFormatA(LOCALE_USER_DEFAULT, TIME_NOSECONDS | LOCALE_USE_CP_ACP, st, NULL, buff3, sizeof(buff3)); ok(ret == lstrlenA(buff3)+1, "got %d\n", ret); - ok(lstrcmpA(buff3, buff + lstrlenA(buff) - lstrlenA(buff3)) == 0, + todo_wine_if(!dstMatch) + ok(lstrcmpA(buff3, buff + lstrlenA(buff) - lstrlenA(buff3)) == 0 || broken(!dstMatch) /* pre Windows 7 */, "expected (%s), got (%s) for time part\n", buff3, buff + lstrlenA(buff) - lstrlenA(buff3)); ret = GetDateFormatA(LOCALE_USER_DEFAULT, DATE_LONGDATE | LOCALE_USE_CP_ACP, st, NULL, buff2, sizeof(buff2)); @@ -1790,7 +1806,8 @@ static void test_SHFormatDateTimeA(const SYSTEMTIME *st) ok(ret == lstrlenA(buff)+1, "got %d\n", ret); ret = GetTimeFormatA(LOCALE_USER_DEFAULT, LOCALE_USE_CP_ACP, st, NULL, buff3, sizeof(buff3)); ok(ret == lstrlenA(buff3)+1, "got %d\n", ret); - ok(lstrcmpA(buff3, buff + lstrlenA(buff) - lstrlenA(buff3)) == 0, + todo_wine_if(!dstMatch) + ok(lstrcmpA(buff3, buff + lstrlenA(buff) - lstrlenA(buff3)) == 0 || broken(!dstMatch) /* pre Windows 7 */, "expected (%s), got (%s) for time part\n", buff3, buff + lstrlenA(buff) - lstrlenA(buff3)); ret = GetDateFormatA(LOCALE_USER_DEFAULT, DATE_LONGDATE | LOCALE_USE_CP_ACP, st, NULL, buff2, sizeof(buff2)); @@ -1808,7 +1825,9 @@ static void test_SHFormatDateTimeA(const SYSTEMTIME *st) ret = GetTimeFormatA(LOCALE_USER_DEFAULT, TIME_NOSECONDS | LOCALE_USE_CP_ACP, st, NULL, buff3, sizeof(buff3)); ok(ret == lstrlenA(buff3)+1, "got %d\n", ret); strcat(buff2, buff3); - ok(lstrcmpA(buff, buff2) == 0, "expected (%s), got (%s)\n", buff2, buff); + todo_wine_if(!dstMatch) + ok(lstrcmpA(buff, buff2) == 0 || broken(!dstMatch) /* pre Windows 7 */, + "expected (%s), got (%s)\n", buff2, buff);
flags = FDTF_NOAUTOREADINGORDER | FDTF_SHORTDATE | FDTF_LONGTIME; ret = pSHFormatDateTimeA(&filetime, &flags, buff, sizeof(buff)); @@ -1819,12 +1838,15 @@ static void test_SHFormatDateTimeA(const SYSTEMTIME *st) ret = GetTimeFormatA(LOCALE_USER_DEFAULT, LOCALE_USE_CP_ACP, st, NULL, buff3, sizeof(buff3)); ok(ret == lstrlenA(buff3)+1, "got %d\n", ret); strcat(buff2, buff3); - ok(lstrcmpA(buff, buff2) == 0, "expected (%s), got (%s)\n", buff2, buff); + todo_wine_if(!dstMatch) + ok(lstrcmpA(buff, buff2) == 0 || broken(!dstMatch) /* pre Windows 7 */, + "expected (%s), got (%s)\n", buff2, buff); }
static void test_SHFormatDateTimeW(void) { FILETIME UNALIGNED filetime; + SYSTEMTIME universalSystemTime; WCHAR buff[100], buff2[100], buff3[100], *p1, *p2; SYSTEMTIME st; DWORD flags; @@ -1840,9 +1862,9 @@ if (0) }
GetLocalTime(&st); - SystemTimeToFileTime(&st, &filetime); /* SHFormatDateTime expects input as utc */ - LocalFileTimeToFileTime(&filetime, &filetime); + TzSpecificLocalTimeToSystemTime(NULL, &st, &universalSystemTime); + SystemTimeToFileTime(&universalSystemTime, &filetime);
/* no way to get required buffer length here */ SetLastError(0xdeadbeef);
From: Jeff Smith whydoubt@gmail.com
--- dlls/shlwapi/ordinal.c | 5 ++--- dlls/shlwapi/tests/ordinal.c | 7 ------- 2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/dlls/shlwapi/ordinal.c b/dlls/shlwapi/ordinal.c index 885da3f2269..6e21bd9e075 100644 --- a/dlls/shlwapi/ordinal.c +++ b/dlls/shlwapi/ordinal.c @@ -4288,7 +4288,6 @@ INT WINAPI SHFormatDateTimeW(const FILETIME UNALIGNED *fileTime, DWORD *flags, #define SHFORMATDT_UNSUPPORTED_FLAGS (FDTF_RELATIVE | FDTF_LTRDATE | FDTF_RTLDATE | FDTF_NOAUTOREADINGORDER) DWORD fmt_flags = flags ? *flags : FDTF_DEFAULT; SYSTEMTIME st; - FILETIME ft; INT ret = 0;
TRACE("%p %p %p %u\n", fileTime, flags, buf, size); @@ -4299,8 +4298,8 @@ INT WINAPI SHFormatDateTimeW(const FILETIME UNALIGNED *fileTime, DWORD *flags, if (fmt_flags & SHFORMATDT_UNSUPPORTED_FLAGS) FIXME("ignoring some flags - 0x%08lx\n", fmt_flags & SHFORMATDT_UNSUPPORTED_FLAGS);
- FileTimeToLocalFileTime(fileTime, &ft); - FileTimeToSystemTime(&ft, &st); + FileTimeToSystemTime(fileTime, &st); + SystemTimeToTzSpecificLocalTime(NULL, &st, &st);
/* first of all date */ if (fmt_flags & (FDTF_LONGDATE | FDTF_SHORTDATE)) diff --git a/dlls/shlwapi/tests/ordinal.c b/dlls/shlwapi/tests/ordinal.c index 1f3c8e28512..4cf3674ec77 100644 --- a/dlls/shlwapi/tests/ordinal.c +++ b/dlls/shlwapi/tests/ordinal.c @@ -1740,7 +1740,6 @@ static void test_SHFormatDateTimeA(const SYSTEMTIME *st) ok(ret == lstrlenA(buff)+1, "got %d\n", ret); ret = GetTimeFormatA(LOCALE_USER_DEFAULT, TIME_NOSECONDS | LOCALE_USE_CP_ACP, st, NULL, buff2, sizeof(buff2)); ok(ret == lstrlenA(buff2)+1, "got %d\n", ret); - todo_wine_if(!dstMatch) ok(lstrcmpA(buff, buff2) == 0 || broken(!dstMatch) /* pre Windows 7 */, "expected (%s), got (%s)\n", buff2, buff);
@@ -1749,7 +1748,6 @@ static void test_SHFormatDateTimeA(const SYSTEMTIME *st) ok(ret == lstrlenA(buff)+1, "got %d\n", ret); ret = GetTimeFormatA(LOCALE_USER_DEFAULT, LOCALE_USE_CP_ACP, st, NULL, buff2, sizeof(buff2)); ok(ret == lstrlenA(buff2)+1, "got %d\n", ret); - todo_wine_if(!dstMatch) ok(lstrcmpA(buff, buff2) == 0 || broken(!dstMatch) /* pre Windows 7 */, "expected (%s), got (%s)\n", buff2, buff);
@@ -1759,7 +1757,6 @@ static void test_SHFormatDateTimeA(const SYSTEMTIME *st) ok(ret == lstrlenA(buff)+1, "got %d\n", ret); ret = GetTimeFormatA(LOCALE_USER_DEFAULT, LOCALE_USE_CP_ACP, st, NULL, buff2, sizeof(buff2)); ok(ret == lstrlenA(buff2)+1, "got %d\n", ret); - todo_wine_if(!dstMatch) ok(lstrcmpA(buff, buff2) == 0 || broken(!dstMatch) /* pre Windows 7 */, "expected (%s), got (%s)\n", buff2, buff);
@@ -1791,7 +1788,6 @@ static void test_SHFormatDateTimeA(const SYSTEMTIME *st) ok(ret == lstrlenA(buff)+1, "got %d, length %d\n", ret, lstrlenA(buff)+1); ret = GetTimeFormatA(LOCALE_USER_DEFAULT, TIME_NOSECONDS | LOCALE_USE_CP_ACP, st, NULL, buff3, sizeof(buff3)); ok(ret == lstrlenA(buff3)+1, "got %d\n", ret); - todo_wine_if(!dstMatch) ok(lstrcmpA(buff3, buff + lstrlenA(buff) - lstrlenA(buff3)) == 0 || broken(!dstMatch) /* pre Windows 7 */, "expected (%s), got (%s) for time part\n", buff3, buff + lstrlenA(buff) - lstrlenA(buff3)); @@ -1806,7 +1802,6 @@ static void test_SHFormatDateTimeA(const SYSTEMTIME *st) ok(ret == lstrlenA(buff)+1, "got %d\n", ret); ret = GetTimeFormatA(LOCALE_USER_DEFAULT, LOCALE_USE_CP_ACP, st, NULL, buff3, sizeof(buff3)); ok(ret == lstrlenA(buff3)+1, "got %d\n", ret); - todo_wine_if(!dstMatch) ok(lstrcmpA(buff3, buff + lstrlenA(buff) - lstrlenA(buff3)) == 0 || broken(!dstMatch) /* pre Windows 7 */, "expected (%s), got (%s) for time part\n", buff3, buff + lstrlenA(buff) - lstrlenA(buff3)); @@ -1825,7 +1820,6 @@ static void test_SHFormatDateTimeA(const SYSTEMTIME *st) ret = GetTimeFormatA(LOCALE_USER_DEFAULT, TIME_NOSECONDS | LOCALE_USE_CP_ACP, st, NULL, buff3, sizeof(buff3)); ok(ret == lstrlenA(buff3)+1, "got %d\n", ret); strcat(buff2, buff3); - todo_wine_if(!dstMatch) ok(lstrcmpA(buff, buff2) == 0 || broken(!dstMatch) /* pre Windows 7 */, "expected (%s), got (%s)\n", buff2, buff);
@@ -1838,7 +1832,6 @@ static void test_SHFormatDateTimeA(const SYSTEMTIME *st) ret = GetTimeFormatA(LOCALE_USER_DEFAULT, LOCALE_USE_CP_ACP, st, NULL, buff3, sizeof(buff3)); ok(ret == lstrlenA(buff3)+1, "got %d\n", ret); strcat(buff2, buff3); - todo_wine_if(!dstMatch) ok(lstrcmpA(buff, buff2) == 0 || broken(!dstMatch) /* pre Windows 7 */, "expected (%s), got (%s)\n", buff2, buff); }