TimeZone application

S

Scott

Hi All,

I have a few questions about timezones, I am currently writting an
application where I am required to manage times in different time
zones. Unfortunaly its not sufficent for me to store UTC time, so I am
storing UTC time and an index to the time zone

eg/
string[] zoneNames = key.GetSubKeyNames();

int index = 0;
foreach (string zoneName in zoneNames)
{
using (RegistryKey subKey =
key.OpenSubKey(zoneName))
{
TimeZoneInformation tzi = new
TimeZoneInformation();
tzi.m_name = zoneName;
tzi.m_displayName =
(string)subKey.GetValue("Display");
tzi.m_standardName =
(string)subKey.GetValue("Std");
tzi.m_daylightName =
(string)subKey.GetValue("Dlt");
tzi.m_index = index;
index++;


tzi.InitTzi((byte[])subKey.GetValue("Tzi"));
int bias = tzi.Bias;
while (zones.ContainsKey(bias))
{
bias++;
}
zones.Add(bias,tzi);
}
}

Now, when I upload this from my local computer to a server, the
timezone seem to load in a different order from the registery.

I feel the way I am indexing the timezones could change with a
timezone patch, is this the case? How is the best way to identify a
timezone?

Regards
Scott
 
G

Guest

What do you want to do with these stored times? If you're storing UTC
timezone is somewhat meaningless, especially if the time goes from one
timezone to another. If you're storing UTC and you want to display the
remote computers local time (with timezone information) then you shouldn't
use UTC. If you want to display the remote local time in another locale you
should store the local time with the time zone information.

Yes, the timezone information from computer to computer may be in a
different order in the registry. The order would depend on what was
originally written to the registry and the order/installation of updates that
affected it. Through Windows Update, updates can expire and get replaced by
another that includes all the updates from the other. If Update 1 was
replaced by Update 2 and Computer A got updated 1 and 2 but Computer B only
got update 2, it's conceivable that Computer A and Computer B would have
different registry ordering (but contain the same data).

Dan Rogers has a good reference for globalizing dates and times:
http://msdn2.microsoft.com/en-us/library/ms973825.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top