It would be useful to be able to canonicalize any instance of TZInfo::Timezone. So, for any linked zone lz, lz.canonical_zone would return the data zone to which it is linked. For any data zone, it would return itself.
Currently, I get can this information, but it seems to require, first, determining whether the zone in question is a linked zone (based on its class) and, second, using the private method info to get at the identifier of its data zone.
In the master branch, it looks like I could load the info from the data source without using private interfaces. However, my dependencies are keeping me on the 0.3 branch for now.
For my current purposes, I only need the canonical identifier, so I've added the following monkey patch to my project:
Thanks for the suggestion. I'll take a look at adding canonical_identifier and/or canonical_zone methods to the TZInfo::Timezone interface. Note that these methods would only be meaningful when used with the TZInfo::Data :ruby data source. Information about links is not present in the zoneinfo files that are used by the :zoneinfo data source supported by TZInfo >= 1.0.0.
Your monkey patch looks to be correct. I might change the LinkedTimezone#canonical_identifier implementation to the following though:
This would allow for the possibility of links via another LinkedTimezone (e.g. LinkedZone1 -> LinkedZone2 -> DataZone). There are no such linked zones in the time zone database at present, and I doubt that any would be added, so this is slightly academic.
Thanks, and I like your improvement of LinkedTimezone#canonical_identifier.
Add canonical_identifier and canonical_zone methods to Timezone.