Search code examples
.netzoneinfo

Is there anyway i can convert a "Australia/Melbourne" time zone into some .net base class library object?


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?


Solution

  • 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.