From 2ac24e7c3fc23741b021a0519afaa4a4bda949a6 Mon Sep 17 00:00:00 2001 From: Silent Date: Fri, 18 Feb 2022 11:22:29 +0100 Subject: [PATCH] Win32: Fix a Y2038 bug in TimeToSystemTime (#16681) --- src/openrct2/platform/Platform.Win32.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/openrct2/platform/Platform.Win32.cpp b/src/openrct2/platform/Platform.Win32.cpp index fd424dc8d2..5435a76d74 100644 --- a/src/openrct2/platform/Platform.Win32.cpp +++ b/src/openrct2/platform/Platform.Win32.cpp @@ -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(ll); - ft.dwHighDateTime = ll >> 32; + ft.dwLowDateTime = time_value.LowPart; + ft.dwHighDateTime = time_value.HighPart; SYSTEMTIME st; FileTimeToSystemTime(&ft, &st);