我有一个跟踪文件,每个事务时间都以 Windows 文件时间格式表示.这些时间数字是这样的:
I have a trace file that each transaction time represented in Windows filetime format. These time numbers are something like this:
您能否告诉我 Unix/Linux 中是否有任何 C/C++ 库可以从这些数字中提取实际时间(特别是秒)?我可以编写自己的提取函数吗?
Would you please let me know if there are any C/C++ library in Unix/Linux to extract actual time (specially second) from these numbers ? May I write my own extraction function ?
很简单:windows 纪元从 1601-01-01T00:00:00Z 开始.它比 UNIX/Linux 时代 (1970-01-01T00:00:00Z) 早 11644473600 秒.Windows 滴答以 100 纳秒为单位.因此,从 UNIX epoch 中获取秒数的函数将如下所示:
it's quite simple: the windows epoch starts 1601-01-01T00:00:00Z. It's 11644473600 seconds before the UNIX/Linux epoch (1970-01-01T00:00:00Z). The Windows ticks are in 100 nanoseconds. Thus, a function to get seconds from the UNIX epoch will be as follows:
#define WINDOWS_TICK 10000000
#define SEC_TO_UNIX_EPOCH 11644473600LL
unsigned WindowsTickToUnixSeconds(long long windowsTicks)
{
return (unsigned)(windowsTicks / WINDOWS_TICK - SEC_TO_UNIX_EPOCH);
}
这篇关于在 Unix/Linux 中将 Windows 文件时间转换为秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!