New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated time zones. #17

MartynasM opened this Issue Sep 13, 2018 · 4 comments


None yet
2 participants

MartynasM commented Sep 13, 2018

Hi. Thanks for this amazing project as it saves us from many headaches.

The miniature issue/inconvenience I am having is that there is no zone attribute to help with eliminating backward compatible time zones. I am interested in displaying all time zones except for deprecated ( ). I see a big incidence between deprecated time zones and the ones listed in IANA Time Zone Database backward file but not complete for example US/Pacific-new or WET.

So my question would be - is there any sense in adding a flag to the time zone data to indicate that the zone is only for backward compatibility.


This comment has been minimized.


philr commented Sep 13, 2018

The TZInfo::Timezone.all_country_zone_identifiers method is probably what you are looking for. This returns an array of all the time zone identifiers that are used by at least one country according to the file (or if using the zoneinfo data source and couldn't be found).

The file only includes current, non-deprecated and non-aliased zone identifiers.

Note that the all_country_zone_identifiers method does not return the fixed offset Etc/GMT+/-n zones (defined in the etcetera file) that Wikipedia lists as canonical. These zones are of little use though because they don't take daylight savings time into account.

The backward file only includes aliases for zones that have been renamed, allowing the old identifier to continue to be used. Some of these are listed by Wikipedia as deprecated, others as aliases. The other zones listed as deprecated by Wikipedia are included as Links or Zones in other source files. For example, US/Pacific-New appears as a Link in the pacificnew file and WET appears as a Zone in the europe file.

When using TZInfo with the Ruby data source (tzinfo-data gem), you can determine if a zone is a fully defined Zone or a Link to (alias for) another by checking whether the canonical_identifier matches the identifier:

tz1 = TZInfo::Timezone.get('America/Los_Angeles')
# => "America/Los_Angeles"
# => "America/Los_Angeles" - matches the identifier, therefore a fully defined zone
tz2 = TZInfo::Timezone.get('US/Pacific-New')
# => "US/Pacific-New"
# => "America/Los_Angeles" - different to the identifier, therefore a linked zone

This comment has been minimized.

MartynasM commented Sep 14, 2018

The issue is that I need some linked zones like Europe/Zagreb which are not deprecated. Croatians are not too happy when they have to choose a Serbian city.


This comment has been minimized.


philr commented Sep 14, 2018

The time zone database only attempts to 'uniquely identify every region where clocks have agreed since 1970'. It does not guarantee that there will be a separate time zone for each country. The names are only to be read by 'experts' and are not intended for end users to see. See for further details.

Croatia only has a single time zone. If you can identify that a user is from Croatia, there is no need to indicate to them that they are using Europe/Belgrade instead of Europe/Zagreb.

Instead of selecting from a list of time zone identifiers, it may be better to allow users to first select their country. If there are multiple time zone options available for the country, the descriptions can be shown to choose from. This would avoid the need to show the potentially controversial and confusing zone identifiers at all.

croatia = TZInfo::Country.get('HR')
# => #<TZInfo::Country: HR>
# => 1
# => "Europe/Belgrade"

australia = TZInfo::Country.get('AU')
# => #<TZInfo::Country: AU>
# => 13 {|i| [i.identifier, i.description] }
# => [["Australia/Lord_Howe", "Lord Howe Island"], ["Antarctica/Macquarie", "Macquarie Island"],["Australia/Hobart", "Tasmania (most areas)"], ["Australia/Currie", "Tasmania (King Island)"], ["Australia/Melbourne", "Victoria"], ["Australia/Sydney", "New South Wales (most areas)"], ["Australia/Broken_Hill", "New South Wales (Yancowinna)"], ["Australia/Brisbane", "Queensland (most areas)"], ["Australia/Lindeman", "Queensland (Whitsunday Islands)"], ["Australia/Adelaide", "South Australia"], ["Australia/Darwin", "Northern Territory"], ["Australia/Perth", "Western Australia (most areas)"], ["Australia/Eucla", "Western Australia (Eucla)"]]

This comment has been minimized.


philr commented Sep 14, 2018

See also tzinfo/tzinfo#60.

@philr philr closed this Oct 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment