Skip to content

Commit

Permalink
Fix a Y2038 bug in UnixTimeToFileTime
Browse files Browse the repository at this point in the history
  • Loading branch information
CookiePLMonster committed Mar 26, 2022
1 parent 51041e4 commit e43f2dd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/common/timestamp.cpp
Expand Up @@ -281,13 +281,13 @@ Timestamp& Timestamp::operator=(const Timestamp& other)

#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)
{
LONGLONG ll;
ll = Int32x32To64(t, 10000000ULL) + 116444736000000000ULL;
pft->dwLowDateTime = (DWORD)ll;
pft->dwHighDateTime = ll >> 32;
ULARGE_INTEGER time_value;
time_value.QuadPart = (t * 10000000LL) + 116444736000000000LL;
pft->dwLowDateTime = time_value.LowPart;
pft->dwHighDateTime = time_value.HighPart;
}
static void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst)
{
Expand Down

0 comments on commit e43f2dd

Please sign in to comment.