Does Windows have a standard enumeration of world timezones?

0

I want to store a date and time in an application where compactness is paramount. As well as the datetime, I want to save the associated timezone. While I could just store the timezone bias -i.e. a number in the range -660..840 it would be better to store something that would enable me to identify the timezone by name when the data is retrieved.

So rather than storing -360 (i.e. GMT-0600) I could distinguish between Central Standard Time and Central Standard time (Mexico).

I notice that the registry has an enumeration of timezones at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\ which includes a key called Index for each entry.

  • Is this index that I am after?
  • Is it documented somewhere?
  • Is the enumeration of this index liable to change in the future?

rossmcm

Posted 2013-04-09T21:11:11.110

Reputation: 1 328

This information is indeed documented on the Microsoft website. The process of accessing this particular registry key also requires elevated permissions. There are many questions that explain how to do this on Stackoverflow. – Ramhound – 2013-04-10T11:39:54.780

Answers

0

I wouldn't rely on the index not changing. While the list looks to be stable, new timezones could be added or existing ones removed which could well shift the indices around. Additionally it's highly likely that that list is different between different versions of Windows (XP, Vista, 7, 8) so if your application is targeting more than one of these it would run into difficulties.

Store the timezone name and then search for that in the registry (or where ever) to select the actual timezone you need.

ChrisF

Posted 2013-04-09T21:11:11.110

Reputation: 39 650

Thanks ChrisF. I don't have the storage for the name (it's an embedded application with very little room). I think maybe the only answer will be to define my own enumeration. – rossmcm – 2013-04-09T22:59:54.330

@rossmcm - You would be talking about a couple hundred KB of storage at most. The storage can't be that limited if it has an embedded version of Windows on it. – Ramhound – 2013-04-10T11:38:51.347

@Ramhound I want to store the TZ info in a small embedded device. The device's data is then read later by a Windows app. When the app reads the TZ info, I want to be able to say "Central European Standard Time", rather than "UTC+1:00". But I only want to store an index in the device, not a string. – rossmcm – 2013-04-11T00:55:23.040

I still say it would only be a couple hundred KB to generate a table of full string names to index values. As I point out this is a well documented feature in the Windows registry. – Ramhound – 2013-04-11T11:27:17.187

@Ramhound storage is limited. We are talking less than 16 kbytes for storage of program and data. Hence I shall store the index (one byte) in the device, and use that to look up the name, etc in a table embedded in the Windows app that talks to the device. – rossmcm – 2013-04-18T04:35:27.547