Charles Petzold on writing books, reading books, and exercising the internal UTM

Recent Entries
< PreviousBrowse the ArchivesNext >
Subscribe to the RSS Feed

ClockRack Fix (But No ClockStrip Fix)

March 18, 2007
New York, N.Y.

Several years ago I wrote a program named ClockRack that was published in the Utilities column of the September 1, 2000 issue of PC Magazine. The program displayed a user-configuration rack of clocks showing current times in places around the world.

Because this program accessed the Windows registry to obtain all its time-zone information, I was quite confident that the program would survive the recent early advent of daylight-saving time. As long as the user's version of Windows was updated, ClockRack would get the new information.

No such luck. The United States changed the advent of DST but Mexico did not, so a differentiation between time zones in the U.S. and those in Mexico is now required. If you look at the Windows registry (run RegEdit and look up HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Time Zones), you'll see how this was done. Three new keys were added:

These new keys are the only keys whose strings don't end with the text "Standard Time." The person whose job it was to add these new keys could have taken a few minutes to examine the existing keys, and he or she would have seen keys like "SA Pacific Standard Time" which refers to a time zone in South America and "US Eastern Standard Time" which refers to Eastern Indiana (which does not observe daylight saving time), and "US Mountain Standard Time" for Arizona (likewise). To maintian consistency, obviously the new time zone keys should have been named "Mexico Central Standard Time" and so forth.

Unfortunately, this little change in formatting broke ClockRack. To store time-zone information, ClockRack created its own keys based on the text of the registry keys up to the text "Standard Time," with the result that it was creating duplicate keys.

Long-time ClockRack user and programmer Jeff Schroeder quickly sent me a patch last Monday morning: In the TziInit function in the ClockRackTzi.c file, begin the second for loop with three new lines:

This new code lets ClockRack store keys like "Central (Mexico)", which would work fine because the keys are used internally only and aren't displayed. However, the ClockRackLst.c file contains a list of cities in North America and their times zone. This list includes Mexico City, which I wanted to change to a time zone of "Mexico Central" rather than the strange-looking "Central (Mexico)." So I wrote an alternative fix like this:

Then I realized that the new registry entry for "Central Standard Time (Mexico)" includes Mexico City in its description, and since ClockRack incorporates those cities as well, I didn't need Mexico City in this ClockRackLst.c file, and I commented it out. So either fix will work.

If you don't have the source code or executable for ClockRack, I can't give it to you. PC Magazine bought "all rights" to the program from me in 2000, and much to my distress, they now charge money for it. The original article and download information are available here. I've sent PC Magazine the revised code and executable, so if you have a subscription to these downloads, an update should be available soon.

If you like the idea of ClockRack but don't want to pay money for it, there is a free alternative. When working on my book Applications = Code + Markup: A Guide to the Microsoft Windows Presentation Foundation., I wrote a WPF version of the program that I cleverly named ClockStrip, and which you can download and install from that page of my Web site. ClockStrip runs under Windows Vista and Windows XP with .NET 3.0 installed. It doesn't have all the features of ClockRack (in particular, you can't make it an application desktop toolbar) but the programs are quite similar in other respects. Fortunately the logic used by ClockStrip to store time-zone information from the registry takes a slightly different approach and isn't affected by the change in the registry keys.

ClockStrip was originally supposed to be part of my WPF book, but we ran out of pages. I have a completed chapter and source code, and I can probably get it posted to my Web site with a half-day or so of work, if anybody is interested.

The original fix worked under Vista but not XP, which used different register keys. Here's a better fix:

Recent Entries
< PreviousBrowse the ArchivesNext >
Subscribe to the RSS Feed

(c) Copyright Charles Petzold