Merge pull request #2814 from CookiePLMonster/y2038

Fix a Y2038 bug in UnixTimeToFileTime
This commit is contained in:
Connor McLaughlin 2022-03-27 17:47:35 +10:00 committed by GitHub
commit 07d331deca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -281,13 +281,13 @@ Timestamp& Timestamp::operator=(const Timestamp& other)
#if defined(_WIN32) #if defined(_WIN32)
// http://support.microsoft.com/kb/167296 // https://docs.microsoft.com/en-us/windows/win32/sysinfo/converting-a-time-t-value-to-a-file-time
static void UnixTimeToFileTime(time_t t, LPFILETIME pft) static void UnixTimeToFileTime(time_t t, LPFILETIME pft)
{ {
LONGLONG ll; ULARGE_INTEGER time_value;
ll = Int32x32To64(t, 10000000ULL) + 116444736000000000ULL; time_value.QuadPart = (t * 10000000LL) + 116444736000000000LL;
pft->dwLowDateTime = (DWORD)ll; pft->dwLowDateTime = time_value.LowPart;
pft->dwHighDateTime = ll >> 32; pft->dwHighDateTime = time_value.HighPart;
} }
static void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst) static void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst)
{ {