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

Closed
MartynasM opened this Issue Sep 13, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@MartynasM

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 ( https://en.wikipedia.org/wiki/List_of_tz_database_time_zones ). 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.

@philr

This comment has been minimized.

Member

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 zone1970.tab file (or zone.tab if using the zoneinfo data source and zone1970.tab couldn't be found).

The zone1970.tab 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:

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

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.

@philr

This comment has been minimized.

Member

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 https://data.iana.org/time-zones/theory.html#naming 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>
croatia.zone_info.length
# => 1
croatia.zone_info[0].identifier
# => "Europe/Belgrade"

australia = TZInfo::Country.get('AU')
# => #<TZInfo::Country: AU>
australia.zone_info.length
# => 13
australia.zone_info.map {|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)"]]
@philr

This comment has been minimized.

Member

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