Tuesday 26 June 2007

Windows time change

When I mentioned yesterday about time zones, it reminded me of an issue I came across a few years ago with the Windows WM_TIMECHANGE message.

Whenever the time is changed on Windows, the WM_TIMECHANGE message is broadcast for any applications to handle if they wish. This was something that was extremely useful to us for our Time & Attendance software because it meant, in theory, that if the time changed on the server that was connected to all of the clocking terminals (on which employees swipe their badges), we would receive the Windows message and send out a time change to the terminals immediately.

This worked really well while I was changing the time on the PC manually; the WM_TIMECHANGE message was issued and our software was issuing out the new time to the terminals.

What this was really designed for though was when the clocks go forward and back, between BST (British Summer Time) and GMT. I knew Windows automatically changed the time on the PC as long as the regional settings were correct, and so I wanted to be able to tap into this and have the terminals updated to the new time as soon as the clock change occured.

But guess what... Windows doesn't issue a WM_TIMECHANGE message when it changes the time for daylight savings. Now that's consistency...

1 comment:

Fernando Madruga said...

Actually, that "can" be consistency! :)

In reality, the time does *not* change, only *appears* to change because you're now in or out of DST, that is, your time appears to be 1 hour forward or behind what it was but only the DST was changed.

Visually, it *looks* as if the time has changed as you look at your computer's clock and see it 1 hour later or sooner than what it was, and Windows will also give you a popup reminding you of that change.

If you look at TIME_ZONE_INFORMATION from MSDN, you'll notice that they keep a "non-DST" "bias" and a DST bias that is the "the difference, in minutes, between Coordinated Universal Time (UTC) and local time".

My guess would be that there is some other msg broadcast when a DST change occurs, but in a few minutes googling I couldn't find which one it is...