Created
July 25, 2019 19:23
-
-
Save CommanderPho/7bd2f6195a5756edbbe2065828f23c1c to your computer and use it in GitHub Desktop.
Converts a Win32 FileTime into a POSIX LONGLONG Timestamp. Credit (https://www.frenk.com/2009/12/convert-filetime-to-unix-timestamp/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Converts a windows FILETIME structure to a POSIX timestamp | |
// https://www.frenk.com/2009/12/convert-filetime-to-unix-timestamp/ | |
LONGLONG FileTime_to_POSIX(FILETIME ft) | |
{ | |
// takes the last modified date | |
LARGE_INTEGER date, adjust; | |
date.HighPart = ft.dwHighDateTime; | |
date.LowPart = ft.dwLowDateTime; | |
// 100-nanoseconds = milliseconds * 10000 | |
adjust.QuadPart = 11644473600000 * 10000; | |
// removes the diff between 1970 and 1601 | |
date.QuadPart -= adjust.QuadPart; | |
// converts back from 100-nanoseconds to seconds | |
return date.QuadPart / 10000000; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment