Win32: Fix a Y2038 bug in TimeToSystemTime (#16681)

This commit is contained in:
Silent authored and GitHub committed 2022-02-18 10:22:29 +00:00
1 parent 2b4579bd93
commit 2ac24e7c3f
1 file changed
+4 -3
+4 -3
View File
@@ -185,11 +185,12 @@ namespace Platform
static SYSTEMTIME TimeToSystemTime(std::time_t timestamp)
{
LONGLONG ll = Int32x32To64(timestamp, 10000000) + 116444736000000000;
ULARGE_INTEGER time_value;
time_value.QuadPart = (timestamp * 10000000LL) + 116444736000000000LL;
FILETIME ft;
ft.dwLowDateTime = static_cast<DWORD>(ll);
ft.dwHighDateTime = ll >> 32;
ft.dwLowDateTime = time_value.LowPart;
ft.dwHighDateTime = time_value.HighPart;
SYSTEMTIME st;
FileTimeToSystemTime(&ft, &st);