Windows filetime time starts from 1601/01/01 to 0 minutes and 0 seconds, windows each clock tick will count plus one, each clock tick interval is nanoseconds (nanosecond, 1 seconds =10 Nine square nanoseconds), that is, each clock tick = 10 (-7) seconds.
UNIX, Linux time is counting from 1970/01/01 to 0 minutes and 0 seconds, counting plus 1 per second. The time interval between 197001/01 and 1601/01/01 is 11,644,473,600 seconds.
So the code to convert from Windows tick time to Unix time is:
#define Windows_tick 10000000 //10 7-Square # # Sec_to_unix_epoch 11644473600LL//1601 with 1970 time interval unsigned Windowsticktounixseconds (Long long windowsticks) { return (unsigned) (windowsticks/windows_tick-sec_to_unix_ EPOCH);}
The code converted from Timeval to FILETIME is:
void Filetimetotimeval (FILETIME *pfiletime, struct timeval *ptimeval) { calcoffsetfrom1601to1970 ();// 11644473600ll*10^7 Ulonglong ul64filetime = 0; Ul64filetime |= pfiletime->dwhighdatetime; Ul64filetime <<=; Ul64filetime |= pfiletime->dwlowdatetime; Ul64filetime-= g_ulloffsetfrom1601to1970; Ptimeval->tv_sec = (long) (ul64filetime/10000000); Ptimeval->tv_usec = (long) ((ul64filetime% 10000000)/10);} void Timevaltofiletime (struct timeval *ptimeval, FILETIME *pfiletime) { calcoffsetfrom1601to1970 (); ULONGLONG x = ptimeval->tv_sec * nspersec + ptimeval->tv_usec *; x + = g_ulloffsetfrom1601to1970; Pfiletime->dwhighdatetime = (ULONG) (x >> +); Pfiletime->dwlowdatetime = (ULONG) x;}
Conversion of Windows FILETIME to Unix time