A question about the FileTimeToLocalFileTime function turned out to be something else

A customer reported that their program was running into problems with the File­Time­To­Local­File­Time function. Specifically, they found that the values reported by the function varied wildly for different time zones. Even though the two time zones were only a few hours apart, the results were hundreds of centuries apart. The customer did a very good…

16

Converting from a UTC-based SYSTEMTIME directly to a local-time-based SYSTEMTIME

Last year, I presented this commutative diagram A 2-by-2 grid of boxes. The top row is labeled FILE­TIME; the bottom row is labeled SYSTEM­TIME. The first column is labeled UTC; the second column is labeled Local. The upper left box is labeled Get­System­Time­As­File­Time. There is an outgoing arrow to the right labeled File­Time­To­Local­File­Time leading to…

18

On the various ways of getting the current time and date in Win32

There are a number of functions in Win32 that obtain the current date and time. Here’s how they fit together: The starting point is Get­System­Time­As­File­Time. This returns the current time in UTC in the form of a FILE­TIME structure. This also happens to be the time format used internally by the system, so this value…

40

Why do Explorer and the command prompt interpret file times differently?

A customer observed that if they use Explorer to view the timestamp on a file, it is not always in agreement with the value shown if they run a plain DIR in a command prompt. They are sometimes off by an hour. Why is that? Whenever you hear the phrase “off by an hour” you…

27

How do I parse a string into a FILETIME?

Public Service Announcement: Daylight Saving Time ends in most parts of the United States this weekend. Other parts of the world may change on a different day from the United States. The NLS functions in Win32 provide functions to convert a SYSTEMTIME into a string, but it does not provide any functions to perform the…

5

To some people, time zones are just a fancy way of sounding important

As I noted some time ago, there is a standard series of announcements that are sent out when a server is undergoing planned (or unplanned) maintenance. And since these are official announcements, the authors want to sound official. One way of sounding official is to give the times during which the outage will take place…

42

How do I generate a unique 32-bit value for a time zone?

Public Service Announcement: Daylight Saving Time ends in most parts of the United States this weekend. Other parts of the world may change on a different day from the United States. A customer asked the following question: Given two TIME_ZONE_INFORMATION structures, I would like to compute a LONG for each that I can then compare…

8

Why does my TIME_ZONE_INFORMATION have the wrong DST cutover date?

Public Service Announcement: Daylight Saving Time begins in most parts of the United States this weekend. Other parts of the world may change on a different day from the United States. A customer reported that they were getting incorrect values from the GetTimeZoneInformationForYear function. I have a program that calls GetTimeZoneInformationForYear, and it looks like…

30

Why does the Win32 Time service require the date to be correct before it will set the time?

Public Service Announcement: Daylight Saving Time ends in most parts of the United States this weekend. Andy points out that if you attempt to synchronize your clock when the date is set incorrectly, the operation fails with the error message “An error occurred while Windows was synchronizing with time.windows.com. For security reasons, Windows cannot synchronize…

43

Why does the OLE variant date format use 30 December 1899 as its zero point?

In 2006, via the suggestion box, Chris J asks why the OLE variant date format has such a strange zero point. Its zero point is 30 December 1899, as opposed to 1 January 1900 (SQL Server’s zero point) or 1 January 1970 (the unix zero point). It turns out I don’t have to answer this because…

14