Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

TimeZone application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Scott - 24 Oct 2007 13:54 GMT
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
Peter Ritchie [C# MVP] - 24 Oct 2007 16:39 GMT
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

Signature

Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#

> Hi All,
>
[quoted text clipped - 44 lines]
> Regards
> Scott

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.