troubleshooting Question

Olson time

Avatar of praveen1981
praveen1981Flag for India asked on
ProgrammingASP.NETVisual Basic.NET
5 Comments1 Solution815 ViewsLast Modified:
Hi,

I am getting all the system Time Zones, now I am matching the Olson timexone with system
time zone, if matches then returning the system timezone i.e  windowsTimeZone.

now the problem is when I am using "America/New_York" it is returning the correct
"Eastern Standard Time"  but when i am using "America/Nassau" it is not returning the
"Eastern Standard Time"  it just returning the blank,

so, can you please guide me what's wrong in the follwoing code.

                        Many thanks.
 
 private void button1_Click(object sender, EventArgs e)
        {
            //MessageBox.Show(GetWindowTimeZone("America/New_York"));
            MessageBox.Show(GetWindowTimeZone("America/Nassau"));           
        }

        private string GetWindowTimeZone(string oslon)
        {
            string windowsTimeZone = null;
            TzdbDateTimeZoneSource Tzdb = new TzdbDateTimeZoneSource("NodaTime.TimeZones.Tzdb");

            //getting all the system time zones and matching with the Olson time zone
            foreach(TimeZoneInfo timeZone in TimeZoneInfo.GetSystemTimeZones())
            {
                System.Diagnostics.Debug.WriteLine(timeZone.StandardName + " -- " + Tzdb.MapTimeZoneId(timeZone));
                if (Tzdb.MapTimeZoneId(timeZone) == oslon)
                {
                    windowsTimeZone = timeZone.StandardName;
                    break;
                }
            }

            return windowsTimeZone;
        }
ASKER CERTIFIED SOLUTION
Manoj Patil
Technical Lead

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros