praveen1981
asked on
Olson time
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.
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
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.
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks.
Open in new window
So your code is not wrong, the data is missing.