Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?
share|improve this question
    
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 Apr 10 '13 at 11:39

1 Answer 1

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.

share|improve this answer
    
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 Apr 9 '13 at 22:59
    
@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 Apr 10 '13 at 11:38
    
@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 Apr 11 '13 at 0:55
    
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 Apr 11 '13 at 11:27
    
@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 Apr 18 '13 at 4:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.