The conversion between Olson and Windows time Id's has come up multiple times on SO; with many people suggesting Jon Skeet's Noda Time for this task.
Whilst the Google Code page states that there is a function to convert between the two, I can't find details anywhere of how to do this.
Can anyone point me in the right direction?
No, unfortunately we don't have a mapping that way round (Windows to Olson) at the moment.
All of the "provider" interface is slightly up in the air right now:
In other words: sorry, we don't support this at the moment, but we'll bear it in mind when trying to finalize the 1.0 API.
TzdbTimeZoneProvider
support conversion from Windows to Olson, butBclTimeZoneProvider
(provider for windows time zones) does not have correct implementation ofMapTimeZoneId
method and interface seems wrong...Here is implementation at
TzdbTimeZoneProvider
:Note: the windowsIdMap is a dictionary
Here is implementation at
BclTimeZoneProvider
:Note: It just return id of windows time zone.
It seems more correct interface for this method will be:
Then both implementations can be done correctly. I guess you can put this question at Noda Time google groups.
For now you can look into
TzdbTimeZoneProvider
to find way how to map from Olson to Windows tz (simple iteration through the windowsIdMap values).