Win32 FILETIME to POSIX and back
Posted: Sat Nov 13, 2010 7:37 am
Additional information here:
http://support.microsoft.com/kb/167296
http://frenk.wordpress.com/2009/12/14/c ... timestamp/
http://en.allexperts.com/q/C-1040/time- ... indows.htm
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
http://coding.derkeiler.com/Archive/PHP ... 00307.html
Example:
http://support.microsoft.com/kb/167296
http://frenk.wordpress.com/2009/12/14/c ... timestamp/
http://en.allexperts.com/q/C-1040/time- ... indows.htm
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
http://coding.derkeiler.com/Archive/PHP ... 00307.html
Code: Select all
;/ FILETIME is a 64-bit unsigned integer representing the number of
;/ 100-nanosecond intervals since January 1, 1601 UNIX timestamp is number
;/ of seconds since January 1, 1970.
;/ 116444736000000000 = 10000000 * 60 * 60 * 24 * 365 * 369 + 89 leap days
;/ POSIX time is in milliseconds
Procedure.q Time_FileTimeToPOSIX(FileTime.q, LocalTime.b=#False)
If LocalTime
FileTimeToLocalFileTime_(@FileTime.q,@FileTime.q)
EndIf
FileTime.q=(FileTime.q-116444736000000000)/10000000
ProcedureReturn FileTime.q
EndProcedure
;/ FileTime is in the 100s of nanoseconds
Procedure.q Time_POSIXToFileTime(POSIX.q, LocalTime.b=#False)
POSIX.q=(POSIX.q*10000000)+116444736000000000
If LocalTime
LocalFileTimeToFileTime_(@POSIX.q,@POSIX.q)
EndIf
ProcedureReturn POSIX.q
EndProcedure
Code: Select all
Time.q=Date()
Debug Time
Time=Time_POSIXToFileTime(Time)
Debug Time
Time=Time_FileTimeToPOSIX(Time)
Debug Time
Debug FormatDate("%mm/%dd/%yyyy %hh:%ii:%ss",Time)