tags:

views:

244

answers:

2

Hi folks,

I have some data from a 3rd party that includes some string Language property data. Some sample data retrieved looks like :

"Australia/Melbourne"

When i investigated that what the property data-type was based on, it's a Zone Info (tz database / Olson database). Wtf is that? i googled and here's the info....

Sounds like it's used by many major platforms ... but not .NET.

So, before i reinvent the wheel (or, more to the point, update the code from that codeplex site to embed the db list into the dll), does this already exist in the .NET base class library?

A: 

convert it to GMT ? lookup the +x hrs or -x hrs & then subtract the offset from the date/time you have stored. eg. in your example subtract 10, as melbourne is +10 GMT ??

nkav
That doesn't give full time zone information. A time zone is much more than just an offset.
Jon Skeet
+3  A: 

it's a Zone Info (tz database / Olson database). Wtf is that?

It's the portable, pretty much standard way of representing time zones. It's a shame that .NET doesn't support it properly, IMO.

Are you using .NET 3.5? If so, the TimeZoneInfo class is the best support we've got, but converting from the Olson name to the Windows name may be tricky. Ideally you want a conversion from Olson ID to the ID that Windows uses... I don't know that there's one available though.

EDIT: After little bit of digging, a couple of links:

I don't know how often these are kept up to date, but they may well be your best bet.

Jon Skeet
Thanks Jon for the answer. I was afraid .NET doesn't support it .. so i'll just mod that codeplex project to embed the zoneinfo db into the dll, so it's portable. I don't mind NOT converting from olson -> TimeZoneInfo if there's nothing in the bcl. Cheers!
Pure.Krome
Sorry to raise this old post, from the dead ... but Jon, would you have any information why the BCL team don't/haven't supported Zone Info? It it because the data can change? If so, isn't that the same problem with the normal windows clock / daylight savings .. and that's supported... ??
Pure.Krome
I think it's not so much the BCL team as Windows itself - basically it's a different way of "addressing" time zones, and the BCL team chose the Windows way (understandably, though irritatingly).
Jon Skeet