Solved

Olson time

Posted on 2012-12-31
6
714 Views
Last Modified: 2013-11-13
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;
        }

Open in new window

0
Comment
Question by:praveen1981
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 18

Expert Comment

by:Gary Davis
ID: 38734658
I ran the program and listed all the TimeZone IDs and none had "Nassau":

Africa/Cairo
Africa/Casablanca
Africa/Johannesburg
Africa/Lagos
Africa/Nairobi
Africa/Windhoek
America/Anchorage
America/Asuncion
America/Bahia
America/Bogota
America/Buenos_Aires
America/Caracas
America/Cayenne
America/Chicago
America/Chihuahua
America/Cuiaba
America/Denver
America/Godthab
America/Guatemala
America/Halifax
America/Indianapolis
America/La_Paz
America/Los_Angeles
America/Mexico_City
America/Montevideo
America/New_York
America/Phoenix
America/Regina
America/Santa_Isabel
America/Santiago
America/Sao_Paulo
America/St_Johns
Asia/Almaty
Asia/Amman
Asia/Baghdad
Asia/Baku
Asia/Bangkok
Asia/Beirut
Asia/Calcutta
Asia/Colombo
Asia/Damascus
Asia/Dhaka
Asia/Dubai
Asia/Irkutsk
Asia/Jerusalem
Asia/Kabul
Asia/Karachi
Asia/Katmandu
Asia/Krasnoyarsk
Asia/Magadan
Asia/Nicosia
Asia/Novosibirsk
Asia/Rangoon
Asia/Riyadh
Asia/Seoul
Asia/Shanghai
Asia/Singapore
Asia/Taipei
Asia/Tashkent
Asia/Tbilisi
Asia/Tehran
Asia/Tokyo
Asia/Ulaanbaatar
Asia/Vladivostok
Asia/Yakutsk
Asia/Yekaterinburg
Asia/Yerevan
Atlantic/Azores
Atlantic/Cape_Verde
Atlantic/Reykjavik
Australia/Adelaide
Australia/Brisbane
Australia/Darwin
Australia/Hobart
Australia/Perth
Australia/Sydney
Etc/GMT
Etc/GMT+11
Etc/GMT+12
Etc/GMT+2
Etc/GMT-12
Europe/Berlin
Europe/Bucharest
Europe/Budapest
Europe/Istanbul
Europe/Kaliningrad
Europe/Kiev
Europe/London
Europe/Moscow
Europe/Paris
Europe/Warsaw
Indian/Mauritius
Pacific/Apia
Pacific/Auckland
Pacific/Fiji
Pacific/Guadalcanal
Pacific/Honolulu
Pacific/Port_Moresby
Pacific/Tongatapu

Open in new window


So your code is not wrong, the data is missing.
0
 

Author Comment

by:praveen1981
ID: 38735709
Hi,

I got the xml file from following link

http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml 

it contains the following

<mapZone type="America/Nassau" territory="BS" other="Eastern Standard Time"/>

but i don't understand why my code is not returning "America/Nassau"

can you please guide me how could i get it.
0
 
LVL 18

Expert Comment

by:Gary Davis
ID: 38736933
Did you follow the steps for using your own timezone database? See http://noda-time.googlecode.com/hg-history/1.0.x/docs/userguide/tzdb.html

Noda Time comes with a version of the tzdb (aka zoneinfo) database, which is now hosted by IANA. This database changes over time, as countries decide to change their time zone rules. As new versions of Noda Time are released, the version of tzdb will be updated. However, you may wish to use a new version of tzdb without changing which version of Noda Time you're using. This documentation tells you how to do so.
0
 
LVL 19

Accepted Solution

by:
Manoj Patil earned 500 total points
ID: 38749122
0
 

Author Closing Comment

by:praveen1981
ID: 38808832
Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to filter by key press ? 6 54
VB.NET - Refactor Class per SOLID principles 2 33
why JSON Array data not binding on Model ASP.NET ? 1 28
Need help with a query 14 34
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question