0

I'm looking for a way to map a BCL Time Zone value to a Tzdb Time Zone value to get the more expressive values exposed by Tzdb:

For example, I can get BCL time zone as follows. The incomingValue variable is a Microsoft Windows name for the zone, for example Pacific Standard Time from https://support.microsoft.com/en-ca/help/973627/microsoft-time-zone-index-values :

 var bclZone = DateTimeZoneProviders.Bcl.GetZoneOrNull(incomingValue); // ok - it works

Next, what is the best way to then get an equivalent Tzdb zone value (or zones)? I've been fiddling with the following code to no avail.

// The Tzdb provider won't accept a BCL zone value or a Microsoft zone name.
 DateTimeZoneProviders.Tzdb.GetZoneOrNull(.. ? ..);     

The reason I'm asking for this conversion is because the Tzdb zone is more expressive containing abbreviations that can be employed in a tight display scenario, whereas I cannot find abbreviations or other rich values associated with the Microsoft BCL zone type. I'd rather use the Tzdb values than do a manual mapping because I think between these two zone providers they contain everything I need 'out of the box'.

I'm also mulling over using a UTC -/+ calculation to transition to the Tzdb value but am asking here if there is a better approach with noda.

John K
  • 28,441
  • 31
  • 139
  • 229
  • I'm well aware of the `Avoid abbrevations if you possibly can` stipulations because of inherent ambiguities, but have a valid business case for them. https://codeblog.jonskeet.uk/category/nodatime/ re: Time Zone Issue – John K Dec 27 '18 at 15:23
  • This looks like a duplicate of https://stackoverflow.com/questions/17348807 - is it? Note that you can use `TzdbDateTimeZoneSource.WindowsMapping` to get at Windows mapping information within Noda Time as well. (I haven't marked it as a duplicate because I'm unsure.) – Jon Skeet Dec 28 '18 at 09:45
  • You're right. Thank you for pointing me in the right direction. This question is effectively a delicate of https://stackoverflow.com/q/17348807/179972 – John K Jan 13 '19 at 23:10
  • Possible duplicate of [How to translate between Windows and IANA time zones?](https://stackoverflow.com/questions/17348807/how-to-translate-between-windows-and-iana-time-zones) – Jon Skeet Jan 14 '19 at 07:12

0 Answers0