[TZInfo-users] finding equivalent time zones

Philip Ross phil.ross at gmail.com
Sat Mar 2 09:33:27 UTC 2013

Hi David,

The recent changes to allow TZInfo to read data from different sources
do pose a problem for your suggested implementation. TZInfo is now
able to use zoneinfo files (e.g. from /usr/share/zoneinfo) as well as
the Ruby modules (which have now been moved into the separate
tzinfo-data gem).

I'd like to keep the functionality offered by TZInfo the same
regardless of which data source is used. Zoneinfo files only contain
the transitions, so I don't think it would be possible to have an
implementation of your proposed map_equal_zones method that works
equivalently with both types of data source

Are you looking to be able to compare timezones in an application at
runtime or are you interested in pre-computing sets of timezones for
use later?

In the latter case, it may be better to look at modifying
TZInfo::Data::TZDataParser to support comparing timezone observances
in addition to the current functionality.

Kind regards,


On 25 February 2013 17:34, David Byron <dbyron at dbyron.com> wrote:
> Picking up an old thread
> (http://rubyforge.org/pipermail/tzinfo-users/2007-October/000021.html,
> apologies for not setting in-reply-to properly), I had an idea for finding
> equivalent time zones.  I was all ready to go off and implement it, but now
> that tzinfo-data is separate there are more moving parts so I figured I'd
> ask first to see if this has a chance of being accepted upstream.
> My goal is to end up with class method on TZInfo::Timezone something like
> this:
> def self.map_equal_zones(zones,since)
> end
> The return value of this method is a hash with a key for each zone in the
> input zones array.  The value is the primary/master/base zone. Still fishing
> for the right name there.
> The idea is that if you pass TZInfo::Timezone::us_zones and a fairly recent
> date, you only get one of these zones as a value.
> [#<TZInfo::CountryTimezone: America/New_York>,
>  #<TZInfo::CountryTimezone: America/Chicago>,
>  #<TZInfo::CountryTimezone: America/Denver>,
>  #<TZInfo::CountryTimezone: America/Phoenix>,
>  #<TZInfo::CountryTimezone: America/Los_Angeles>,
>  #<TZInfo::CountryTimezone: America/Anchorage>,
>  #<TZInfo::CountryTimezone: America/Adak>,
>  #<TZInfo::CountryTimezone: America/Metlakatla>,
>  #<TZInfo::CountryTimezone: Pacific/Honolulu>]
> My idea for how to do this is to include observance information from data
> files in DataTimezoneInfo, and then compare observances from the given start
> date (since) to figure out what's equal to what.  It seems fairly
> straightforward to include observance info in tzinfo-data/lib/definitions by
> adjusting TZDataZone to write @observances.  From there, it seems similarly
> straightforward to adjust DataTimezoneInfo to provide access to the info.
> No need to parse the rules that the observances reference as far as I can
> tell.
> The decision of what the primary zone is for a given set of equal zones
> would come from the order of the given zones, which with the return value
> from TZInfo::Timezone::us_zones appears to be based on the order in the
> original data files, which is just right for me.
> Thoughts?
> -DB
> _______________________________________________
> TZInfo-users mailing list
> TZInfo-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/tzinfo-users

More information about the TZInfo-users mailing list