转换的Windows FILETIME第二在Unix / Linux操作系统 [英] Convert Windows Filetime to second in Unix/Linux

查看:713
本文介绍了转换的Windows FILETIME第二在Unix / Linux操作系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我每次交易时间重新$ P $在Windows FILETIME格式psented一个跟踪文件。这些时间数字是这样的:

I have a trace file that each transaction time represented in Windows filetime format. These time numbers are something like this:


  • 128166372003061629

  • 128166372016382155

  • 128166372026382245

请你让我知道如果有在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。这是11644473600秒的UNIX / Linux的纪元前(1970-01-01T00:00:00Z)。在Windows蜱是100纳秒。因此,一个函数从UNIX纪元得到秒将如下:

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);
}

这篇关于转换的Windows FILETIME第二在Unix / Linux操作系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆