[DXDIAG] Remove a "redundant" GetTimeZoneInformation() call.

Indeed, the next SystemTimeToTzSpecificLocalTime() call, when done with
a NULL TIME_ZONE_INFORMATION* 1st parameter, uses the currently active
time zone, which is exactly what the GetTimeZoneInformation() call was
doing.

And note that the original code was incorrectly validating the returned
value from GetTimeZoneInformation() -- the code was assuming the function
returns a boolean, instead of checking for TIME_ZONE_ID_INVALID.
This commit is contained in:
Hermès Bélusca-Maïto 2023-09-02 21:44:21 +02:00
parent 8a0e45031e
commit df9c3de5ba
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -18,7 +18,6 @@ GetFileModifyTime(LPCWSTR pFullPath, WCHAR * szTime, int szTimeSize)
FILETIME AccessTime;
SYSTEMTIME SysTime, LocalTime;
UINT Length;
TIME_ZONE_INFORMATION TimeInfo;
hFile = CreateFileW(pFullPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
if (!hFile)
@ -31,13 +30,10 @@ GetFileModifyTime(LPCWSTR pFullPath, WCHAR * szTime, int szTimeSize)
}
CloseHandle(hFile);
if(!GetTimeZoneInformation(&TimeInfo))
return FALSE;
if (!FileTimeToSystemTime(&AccessTime, &SysTime))
return FALSE;
if (!SystemTimeToTzSpecificLocalTime(&TimeInfo, &SysTime, &LocalTime))
if (!SystemTimeToTzSpecificLocalTime(NULL, &SysTime, &LocalTime))
return FALSE;
Length = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &LocalTime, NULL, szTime, szTimeSize);