Windows FILETIME结构是否包含闰秒?

FILETIME http://msdn.microsoft.com/en-us/library/ms724284(VS.85).aspx
结构从1601年1月1日开始(大概是当天的开始)
根据微软文档,但这是否包括闰秒?

注意:在互联网上使用一些时间回答陌生人的问题很慷慨如果你真的不知道答案,那就不是特别有用了。另外,23秒不是一个完全不合理的时间,令人担忧。许多Windows机器的时钟精确到23秒钟内。

问题不应该是FILETIME包括闰秒。

它应该是:

Do the people,functions,and libraries,who interpret a FILETIME (i.e. FileTimetoSystemTime) include leap seconds when counting the duration?

简单的答案是“不”。 FileTimetoSystemTime返回秒为0..59。

更简单的答案是:“当然不,怎么可能?”

我的Windows 2000机器不知道自从发布以来的十年里增加了2个闰秒。对FILETIME的任何解释都是错误的。

最后,我们可以通过直接的实验观察来确定海报的答案,而不是依靠逻辑,

var
    systemTime: TSystemTime;
    fileTime: TFileTime;
begin
    //Construct a system-time for the 12/31/2008 11:59:59 pm
    ZeroMemory(@systemTime,SizeOf(systemTime));
    systemtime.wYear := 2008;
    systemTime.wMonth := 12;
    systemTime.wDay := 31;
    systemTime.wHour := 23;
    systemtime.wMinute := 59;
    systemtime.wSecond := 59;

    //Convert it to a file time
    SystemTimetoFileTime(systemTime,{var}fileTime);

    //There was a leap second 12/31/2008 11:59:60 pm
    //Add one second to our filetime to reach the leap second
    filetime.dwLowDateTime := fileTime.dwLowDateTime+10000000; //10,000,000 * 100ns = 1s

    //Convert the filetime,sitting on a leap second,to a displayable system time
    FileTimetoSystemTime(fileTime,{var}systemTime);

    //And Now print the system time
    ShowMessage(DateTimetoStr(SystemTimetoDateTime(systemTime)));

加一秒钟

12/31/2008 11:59:59pm

1/1/2009 12:00:00am

而不是

1/1/2009 11:59:60pm

证明完毕

原来的海报可能不喜欢,但是上帝故意装备它,以便一年不能被一天分割。他只是为了搞砸程序员。

相关文章

Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...
Windows文件操作基础代码 Windows下对文件进行操作使用的一段...
Winpcap基础代码 使用Winpcap进行网络数据的截获和发送都需要...
使用vbs脚本进行批量编码转换 最近需要使用SourceInsight查看...