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

ActiveSupport::TimeZone.country_zones(country_code) fails to find valid Alpha2 #28431

Closed
darrennix opened this Issue Mar 15, 2017 · 11 comments

Comments

Projects
None yet
8 participants
@darrennix

darrennix commented Mar 15, 2017

Steps to reproduce

ActiveSupport::TimeZone.country_zones('GT')
ActiveSupport::TimeZone.country_zones('SV')

Expected behavior

Guatemala and El Salvador share the same time zone ("Central America") and should return the same TZInfo response array.

Actual behavior

ActiveSupport::TimeZone.country_zones('GT')
=> [#<ActiveSupport::TimeZone:0x007ff9f0c61c08 @name="Central America", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Guatemala>>]
ActiveSupport::TimeZone.country_zones('SV')
=> []

Cause

https://github.com/rails/rails/blob/master/activesupport/lib/active_support/values/time_zone.rb

The underlying reason seems to be that ActiveSupport::TimeZone::MAPPING is only a partial mapping of TZinfo identifiers: "Keys are Rails TimeZone names, values are TZInfo identifiers." As a result, country_zones() will return the correct response only if a Rails TimeZone name is not shared by multiple countries.

Version

ruby 2.3.3p222
activesupport (= 5.0.2)
tzinfo (1.2.2)

@azeezahmed

This comment has been minimized.

Show comment
Hide comment
@azeezahmed

azeezahmed Mar 16, 2017

  • SV is officially assigned country code for America/El_Salvador

  • Also Verified that TZInfo returns as below

TZInfo::Country.get('SV').zone_identifiers

=> ["America/El_Salvador"]

  • However, Mapping used in time_zone.rb seems to be missing:
    "El Salvador" => "America/El_Salvador"

  • If the above line is added we get results as:
    [#<ActiveSupport::TimeZone:0x007f912815b100 @name="El Salvador", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/El_Salvador>>]

  • However, the TZInfo response array will not be same as @darrennix expected.

azeezahmed commented Mar 16, 2017

  • SV is officially assigned country code for America/El_Salvador

  • Also Verified that TZInfo returns as below

TZInfo::Country.get('SV').zone_identifiers

=> ["America/El_Salvador"]

  • However, Mapping used in time_zone.rb seems to be missing:
    "El Salvador" => "America/El_Salvador"

  • If the above line is added we get results as:
    [#<ActiveSupport::TimeZone:0x007f912815b100 @name="El Salvador", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/El_Salvador>>]

  • However, the TZInfo response array will not be same as @darrennix expected.

@espen

This comment has been minimized.

Show comment
Hide comment
@espen

espen commented Mar 27, 2017

See #12461 (comment)

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Mar 27, 2017

Member

@pixeltrix could you review this?

Member

rafaelfranca commented Mar 27, 2017

@pixeltrix could you review this?

@azeezahmed

This comment has been minimized.

Show comment
Hide comment
@azeezahmed

azeezahmed Mar 28, 2017

After going through #12461, I would agree with @pixeltrix
As he stated that "The main purpose of MAPPING is to build the options list for time_zone_select"

And it also says in the documentation that it "Limits the set of zones provided by TZInfo to a meaningful subset of 146 zones." ( which seem more readable to me)

If these 146 defined zones cover everything then it shouldn't be a problem and if at all we need to be specific with a time zone we should be calling out TZInfo.

azeezahmed commented Mar 28, 2017

After going through #12461, I would agree with @pixeltrix
As he stated that "The main purpose of MAPPING is to build the options list for time_zone_select"

And it also says in the documentation that it "Limits the set of zones provided by TZInfo to a meaningful subset of 146 zones." ( which seem more readable to me)

If these 146 defined zones cover everything then it shouldn't be a problem and if at all we need to be specific with a time zone we should be calling out TZInfo.

@pixeltrix pixeltrix self-assigned this Mar 28, 2017

@pixeltrix

This comment has been minimized.

Show comment
Hide comment
@pixeltrix

pixeltrix Mar 28, 2017

Member

This is fixable - working on it

Member

pixeltrix commented Mar 28, 2017

This is fixable - working on it

@pixeltrix pixeltrix closed this in d28c482 Mar 28, 2017

pixeltrix added a commit that referenced this issue Mar 28, 2017

Return unmapped timezones from `country_zones`
If a country doesn't exist in the MAPPINGS hash then create a new
`ActiveSupport::Timezone` instance using the supplied timezone id.

Fixes #28431.

pixeltrix added a commit that referenced this issue Mar 28, 2017

Return unmapped timezones from `country_zones`
If a country doesn't exist in the MAPPINGS hash then create a new
`ActiveSupport::Timezone` instance using the supplied timezone id.

Fixes #28431.
@sgringwe

This comment has been minimized.

Show comment
Hide comment
@sgringwe

sgringwe May 22, 2017

Contributor

@pixeltrix FWIW, this was a breaking change for our app that we are having to build in a workaround for. We validate validates :time_zone, inclusion: { in: ActiveSupport::TimeZone.all.map(&:name) } for any time zone field and by adding time zones to ActiveSupport::TimeZone.us_zones that aren't in ActiveSupport::TimeZone.all, it causes validation issues for new records.

Would it be possible to revert the behavior of us_zones to its previous and introduce a new method, perhaps all_us_zones for this new behavior to avoid the breaking change?

Contributor

sgringwe commented May 22, 2017

@pixeltrix FWIW, this was a breaking change for our app that we are having to build in a workaround for. We validate validates :time_zone, inclusion: { in: ActiveSupport::TimeZone.all.map(&:name) } for any time zone field and by adding time zones to ActiveSupport::TimeZone.us_zones that aren't in ActiveSupport::TimeZone.all, it causes validation issues for new records.

Would it be possible to revert the behavior of us_zones to its previous and introduce a new method, perhaps all_us_zones for this new behavior to avoid the breaking change?

@pixeltrix

This comment has been minimized.

Show comment
Hide comment
@pixeltrix

pixeltrix May 23, 2017

Member

@sgringwe I don't want to revert since it does fix a bug but I'm pretty sure I can come up with a way for us_zones to return what it did previously. I would suggest that using Rails timezone shorthand name in the database as opposed to a proper zone identifier is not a great idea though.

Can you open a new issue and cc me, thanks.

Member

pixeltrix commented May 23, 2017

@sgringwe I don't want to revert since it does fix a bug but I'm pretty sure I can come up with a way for us_zones to return what it did previously. I would suggest that using Rails timezone shorthand name in the database as opposed to a proper zone identifier is not a great idea though.

Can you open a new issue and cc me, thanks.

@BigGillyStyle

This comment has been minimized.

Show comment
Hide comment
@BigGillyStyle

BigGillyStyle May 24, 2017

@pixeltrix In Rails 5.0.2 and prior we used the following method to provide the "available time zones" for our app:

(ActiveSupport::TimeZone.us_zones + [ActiveSupport::TimeZone.all - ActiveSupport::TimeZone.us_zones]).flatten.uniq { |e| e.utc_offset }.sort_by(&:utc_offset)

That logic has been in place untouched since February 25, 2014 (according to git blame). As of Rails 5.0.3 this now returns a different array of zones, which is also now causing validation errors. I suspect this is the same issue that @sgringwe mentioned in his comment?

And just in case it helps to further specify things, here's what I'm seeing in a Rails console. Note, among other differences, that "Hawaii" is no longer in the list.

Rails 5.0.2

Loading development environment (Rails 5.0.2)
irb(main):001:0> (ActiveSupport::TimeZone.us_zones + [ActiveSupport::TimeZone.all - ActiveSupport::TimeZone.us_zones]).flatten.uniq { |e| e.utc_offset }.sort_by(&:utc_offset)
[
    [ 0] #<ActiveSupport::TimeZone:0x00559ecb8da120 @name="American Samoa", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Pago_Pago>>,
    [ 1] #<ActiveSupport::TimeZone:0x00559ecb8ce118 @name="Hawaii", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Honolulu>>,
    [ 2] #<ActiveSupport::TimeZone:0x00559ecb8ad558 @name="Alaska", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Juneau>>,
    [ 3] #<ActiveSupport::TimeZone:0x00559ecb88f418 @name="Pacific Time (US & Canada)", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Los_Angeles>>,
    [ 4] #<ActiveSupport::TimeZone:0x00559ecb849b48 @name="Arizona", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Phoenix>>,
    [ 5] #<ActiveSupport::TimeZone:0x00559ec4c3bb68 @name="Central Time (US & Canada)", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Chicago>>,
    [ 6] #<ActiveSupport::TimeZone:0x00559ec4f8e4c8 @name="Eastern Time (US & Canada)", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/New_York>>,
    [ 7] #<ActiveSupport::TimeZone:0x00559ecb9426a8 @name="Atlantic Time (Canada)", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Halifax>>,
    [ 8] #<ActiveSupport::TimeZone:0x00559eca921170 @name="Newfoundland", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/St_Johns>>,
    [ 9] #<ActiveSupport::TimeZone:0x00559ecb9adfe8 @name="Brasilia", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Sao_Paulo>>,
    [10] #<ActiveSupport::TimeZone:0x00559ecb9fbf68 @name="Mid-Atlantic", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Atlantic/South_Georgia>>,
    [11] #<ActiveSupport::TimeZone:0x00559ecb9fb518 @name="Azores", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Atlantic/Azores>>,
    [12] #<ActiveSupport::TimeZone:0x00559ecbaae8c0 @name="Casablanca", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Africa/Casablanca>>,
    [13] #<ActiveSupport::TimeZone:0x00559ecbc1e048 @name="Amsterdam", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Europe/Amsterdam>>,
    [14] #<ActiveSupport::TimeZone:0x00559ecbd6eda8 @name="Athens", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Europe/Athens>>,
    [15] #<ActiveSupport::TimeZone:0x00559ecc66e480 @name="Baghdad", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Baghdad>>,
    [16] #<ActiveSupport::TimeZone:0x007fbe3001b0f8 @name="Tehran", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Tehran>>,
    [17] #<ActiveSupport::TimeZone:0x007fbe30095830 @name="Abu Dhabi", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Muscat>>,
    [18] #<ActiveSupport::TimeZone:0x00559ecc71f7f8 @name="Kabul", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Kabul>>,
    [19] #<ActiveSupport::TimeZone:0x00559ecc71e9c0 @name="Ekaterinburg", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Yekaterinburg>>,
    [20] #<ActiveSupport::TimeZone:0x00559ecc7a3148 @name="Chennai", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Kolkata>>,
    [21] #<ActiveSupport::TimeZone:0x00559ecc7a1820 @name="Kathmandu", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Kathmandu>>,
    [22] #<ActiveSupport::TimeZone:0x00559ecc7b46f0 @name="Almaty", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Almaty>>,
    [23] #<ActiveSupport::TimeZone:0x00559ecc844278 @name="Rangoon", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Rangoon>>,
    [24] #<ActiveSupport::TimeZone:0x00559ecc85ec18 @name="Bangkok", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Bangkok>>,
    [25] #<ActiveSupport::TimeZone:0x00559ecc8cab48 @name="Beijing", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Shanghai>>,
    [26] #<ActiveSupport::TimeZone:0x00559ecca9bb98 @name="Osaka", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Tokyo>>,
    [27] #<ActiveSupport::TimeZone:0x00559eccad9e48 @name="Adelaide", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Australia/Adelaide>>,
    [28] #<ActiveSupport::TimeZone:0x00559eccaa4018 @name="Brisbane", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Australia/Brisbane>>,
    [29] #<ActiveSupport::TimeZone:0x00559ecc9564b8 @name="Magadan", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Magadan>>,
    [30] #<ActiveSupport::TimeZone:0x00559ecc7c3290 @name="Auckland", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Auckland>>,
    [31] #<ActiveSupport::TimeZone:0x00559ecc6f10b0 @name="Chatham Is.", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Chatham>>,
    [32] #<ActiveSupport::TimeZone:0x00559ecc71edf8 @name="Nuku'alofa", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Tongatapu>>
]

Rails 5.0.3

Loading development environment (Rails 5.0.3)
irb(main):001:0> (ActiveSupport::TimeZone.us_zones + [ActiveSupport::TimeZone.all - ActiveSupport::TimeZone.us_zones]).flatten.uniq { |e| e.utc_offset }.sort_by(&:utc_offset)
[
    [ 0] #<ActiveSupport::TimeZone:0x005595392cb978 @name="American Samoa", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Pago_Pago>>,
    [ 1] #<ActiveSupport::TimeZone:0x005595314be530 @name="America/Adak", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Adak>>,
    [ 2] #<ActiveSupport::TimeZone:0x00559532855c88 @name="Alaska", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Juneau>>,
    [ 3] #<ActiveSupport::TimeZone:0x00559532c24698 @name="Pacific Time (US & Canada)", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Los_Angeles>>,
    [ 4] #<ActiveSupport::TimeZone:0x00559532c36668 @name="America/Boise", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Boise>>,
    [ 5] #<ActiveSupport::TimeZone:0x005595344c68b8 @name="America/Indiana/Knox", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Indiana/Knox>>,
    [ 6] #<ActiveSupport::TimeZone:0x0055953486a460 @name="America/Detroit", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Detroit>>,
    [ 7] #<ActiveSupport::TimeZone:0x00559538febf00 @name="Atlantic Time (Canada)", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Halifax>>,
    [ 8] #<ActiveSupport::TimeZone:0x0055953932a9c8 @name="Newfoundland", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/St_Johns>>,
    [ 9] #<ActiveSupport::TimeZone:0x0055953906b908 @name="Brasilia", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Sao_Paulo>>,
    [10] #<ActiveSupport::TimeZone:0x00559538f0d8e0 @name="Mid-Atlantic", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Atlantic/South_Georgia>>,
    [11] #<ActiveSupport::TimeZone:0x00559538f0ce90 @name="Azores", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Atlantic/Azores>>,
    [12] #<ActiveSupport::TimeZone:0x00559538fd8248 @name="Casablanca", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Africa/Casablanca>>,
    [13] #<ActiveSupport::TimeZone:0x005595391f7a38 @name="Amsterdam", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Europe/Amsterdam>>,
    [14] #<ActiveSupport::TimeZone:0x005595393947d8 @name="Athens", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Europe/Athens>>,
    [15] #<ActiveSupport::TimeZone:0x00559539346790 @name="Baghdad", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Baghdad>>,
    [16] #<ActiveSupport::TimeZone:0x005595393326a0 @name="Tehran", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Tehran>>,
    [17] #<ActiveSupport::TimeZone:0x005595393134f8 @name="Abu Dhabi", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Muscat>>,
    [18] #<ActiveSupport::TimeZone:0x00559539229b00 @name="Kabul", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Kabul>>,
    [19] #<ActiveSupport::TimeZone:0x00559539228a20 @name="Ekaterinburg", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Yekaterinburg>>,
    [20] #<ActiveSupport::TimeZone:0x005595392bf7b8 @name="Chennai", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Kolkata>>,
    [21] #<ActiveSupport::TimeZone:0x005595392bda30 @name="Kathmandu", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Kathmandu>>,
    [22] #<ActiveSupport::TimeZone:0x005595392afef8 @name="Almaty", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Almaty>>,
    [23] #<ActiveSupport::TimeZone:0x0055953927d778 @name="Rangoon", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Rangoon>>,
    [24] #<ActiveSupport::TimeZone:0x00559539277f80 @name="Bangkok", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Bangkok>>,
    [25] #<ActiveSupport::TimeZone:0x00559539252410 @name="Beijing", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Shanghai>>,
    [26] #<ActiveSupport::TimeZone:0x005595391ab908 @name="Osaka", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Tokyo>>,
    [27] #<ActiveSupport::TimeZone:0x00559539183cc8 @name="Adelaide", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Australia/Adelaide>>,
    [28] #<ActiveSupport::TimeZone:0x005595390e8c78 @name="Brisbane", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Australia/Brisbane>>,
    [29] #<ActiveSupport::TimeZone:0x005595392bb050 @name="Magadan", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Magadan>>,
    [30] #<ActiveSupport::TimeZone:0x00559539063640 @name="Auckland", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Auckland>>,
    [31] #<ActiveSupport::TimeZone:0x00559539389680 @name="Chatham Is.", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Chatham>>,
    [32] #<ActiveSupport::TimeZone:0x00559538ee2af0 @name="Nuku'alofa", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Tongatapu>>
]

BigGillyStyle commented May 24, 2017

@pixeltrix In Rails 5.0.2 and prior we used the following method to provide the "available time zones" for our app:

(ActiveSupport::TimeZone.us_zones + [ActiveSupport::TimeZone.all - ActiveSupport::TimeZone.us_zones]).flatten.uniq { |e| e.utc_offset }.sort_by(&:utc_offset)

That logic has been in place untouched since February 25, 2014 (according to git blame). As of Rails 5.0.3 this now returns a different array of zones, which is also now causing validation errors. I suspect this is the same issue that @sgringwe mentioned in his comment?

And just in case it helps to further specify things, here's what I'm seeing in a Rails console. Note, among other differences, that "Hawaii" is no longer in the list.

Rails 5.0.2

Loading development environment (Rails 5.0.2)
irb(main):001:0> (ActiveSupport::TimeZone.us_zones + [ActiveSupport::TimeZone.all - ActiveSupport::TimeZone.us_zones]).flatten.uniq { |e| e.utc_offset }.sort_by(&:utc_offset)
[
    [ 0] #<ActiveSupport::TimeZone:0x00559ecb8da120 @name="American Samoa", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Pago_Pago>>,
    [ 1] #<ActiveSupport::TimeZone:0x00559ecb8ce118 @name="Hawaii", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Honolulu>>,
    [ 2] #<ActiveSupport::TimeZone:0x00559ecb8ad558 @name="Alaska", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Juneau>>,
    [ 3] #<ActiveSupport::TimeZone:0x00559ecb88f418 @name="Pacific Time (US & Canada)", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Los_Angeles>>,
    [ 4] #<ActiveSupport::TimeZone:0x00559ecb849b48 @name="Arizona", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Phoenix>>,
    [ 5] #<ActiveSupport::TimeZone:0x00559ec4c3bb68 @name="Central Time (US & Canada)", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Chicago>>,
    [ 6] #<ActiveSupport::TimeZone:0x00559ec4f8e4c8 @name="Eastern Time (US & Canada)", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/New_York>>,
    [ 7] #<ActiveSupport::TimeZone:0x00559ecb9426a8 @name="Atlantic Time (Canada)", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Halifax>>,
    [ 8] #<ActiveSupport::TimeZone:0x00559eca921170 @name="Newfoundland", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/St_Johns>>,
    [ 9] #<ActiveSupport::TimeZone:0x00559ecb9adfe8 @name="Brasilia", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Sao_Paulo>>,
    [10] #<ActiveSupport::TimeZone:0x00559ecb9fbf68 @name="Mid-Atlantic", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Atlantic/South_Georgia>>,
    [11] #<ActiveSupport::TimeZone:0x00559ecb9fb518 @name="Azores", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Atlantic/Azores>>,
    [12] #<ActiveSupport::TimeZone:0x00559ecbaae8c0 @name="Casablanca", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Africa/Casablanca>>,
    [13] #<ActiveSupport::TimeZone:0x00559ecbc1e048 @name="Amsterdam", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Europe/Amsterdam>>,
    [14] #<ActiveSupport::TimeZone:0x00559ecbd6eda8 @name="Athens", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Europe/Athens>>,
    [15] #<ActiveSupport::TimeZone:0x00559ecc66e480 @name="Baghdad", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Baghdad>>,
    [16] #<ActiveSupport::TimeZone:0x007fbe3001b0f8 @name="Tehran", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Tehran>>,
    [17] #<ActiveSupport::TimeZone:0x007fbe30095830 @name="Abu Dhabi", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Muscat>>,
    [18] #<ActiveSupport::TimeZone:0x00559ecc71f7f8 @name="Kabul", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Kabul>>,
    [19] #<ActiveSupport::TimeZone:0x00559ecc71e9c0 @name="Ekaterinburg", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Yekaterinburg>>,
    [20] #<ActiveSupport::TimeZone:0x00559ecc7a3148 @name="Chennai", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Kolkata>>,
    [21] #<ActiveSupport::TimeZone:0x00559ecc7a1820 @name="Kathmandu", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Kathmandu>>,
    [22] #<ActiveSupport::TimeZone:0x00559ecc7b46f0 @name="Almaty", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Almaty>>,
    [23] #<ActiveSupport::TimeZone:0x00559ecc844278 @name="Rangoon", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Rangoon>>,
    [24] #<ActiveSupport::TimeZone:0x00559ecc85ec18 @name="Bangkok", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Bangkok>>,
    [25] #<ActiveSupport::TimeZone:0x00559ecc8cab48 @name="Beijing", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Shanghai>>,
    [26] #<ActiveSupport::TimeZone:0x00559ecca9bb98 @name="Osaka", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Tokyo>>,
    [27] #<ActiveSupport::TimeZone:0x00559eccad9e48 @name="Adelaide", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Australia/Adelaide>>,
    [28] #<ActiveSupport::TimeZone:0x00559eccaa4018 @name="Brisbane", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Australia/Brisbane>>,
    [29] #<ActiveSupport::TimeZone:0x00559ecc9564b8 @name="Magadan", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Magadan>>,
    [30] #<ActiveSupport::TimeZone:0x00559ecc7c3290 @name="Auckland", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Auckland>>,
    [31] #<ActiveSupport::TimeZone:0x00559ecc6f10b0 @name="Chatham Is.", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Chatham>>,
    [32] #<ActiveSupport::TimeZone:0x00559ecc71edf8 @name="Nuku'alofa", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Tongatapu>>
]

Rails 5.0.3

Loading development environment (Rails 5.0.3)
irb(main):001:0> (ActiveSupport::TimeZone.us_zones + [ActiveSupport::TimeZone.all - ActiveSupport::TimeZone.us_zones]).flatten.uniq { |e| e.utc_offset }.sort_by(&:utc_offset)
[
    [ 0] #<ActiveSupport::TimeZone:0x005595392cb978 @name="American Samoa", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Pago_Pago>>,
    [ 1] #<ActiveSupport::TimeZone:0x005595314be530 @name="America/Adak", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Adak>>,
    [ 2] #<ActiveSupport::TimeZone:0x00559532855c88 @name="Alaska", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Juneau>>,
    [ 3] #<ActiveSupport::TimeZone:0x00559532c24698 @name="Pacific Time (US & Canada)", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Los_Angeles>>,
    [ 4] #<ActiveSupport::TimeZone:0x00559532c36668 @name="America/Boise", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Boise>>,
    [ 5] #<ActiveSupport::TimeZone:0x005595344c68b8 @name="America/Indiana/Knox", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Indiana/Knox>>,
    [ 6] #<ActiveSupport::TimeZone:0x0055953486a460 @name="America/Detroit", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Detroit>>,
    [ 7] #<ActiveSupport::TimeZone:0x00559538febf00 @name="Atlantic Time (Canada)", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Halifax>>,
    [ 8] #<ActiveSupport::TimeZone:0x0055953932a9c8 @name="Newfoundland", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/St_Johns>>,
    [ 9] #<ActiveSupport::TimeZone:0x0055953906b908 @name="Brasilia", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: America/Sao_Paulo>>,
    [10] #<ActiveSupport::TimeZone:0x00559538f0d8e0 @name="Mid-Atlantic", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Atlantic/South_Georgia>>,
    [11] #<ActiveSupport::TimeZone:0x00559538f0ce90 @name="Azores", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Atlantic/Azores>>,
    [12] #<ActiveSupport::TimeZone:0x00559538fd8248 @name="Casablanca", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Africa/Casablanca>>,
    [13] #<ActiveSupport::TimeZone:0x005595391f7a38 @name="Amsterdam", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Europe/Amsterdam>>,
    [14] #<ActiveSupport::TimeZone:0x005595393947d8 @name="Athens", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Europe/Athens>>,
    [15] #<ActiveSupport::TimeZone:0x00559539346790 @name="Baghdad", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Baghdad>>,
    [16] #<ActiveSupport::TimeZone:0x005595393326a0 @name="Tehran", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Tehran>>,
    [17] #<ActiveSupport::TimeZone:0x005595393134f8 @name="Abu Dhabi", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Muscat>>,
    [18] #<ActiveSupport::TimeZone:0x00559539229b00 @name="Kabul", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Kabul>>,
    [19] #<ActiveSupport::TimeZone:0x00559539228a20 @name="Ekaterinburg", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Yekaterinburg>>,
    [20] #<ActiveSupport::TimeZone:0x005595392bf7b8 @name="Chennai", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Kolkata>>,
    [21] #<ActiveSupport::TimeZone:0x005595392bda30 @name="Kathmandu", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Kathmandu>>,
    [22] #<ActiveSupport::TimeZone:0x005595392afef8 @name="Almaty", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Almaty>>,
    [23] #<ActiveSupport::TimeZone:0x0055953927d778 @name="Rangoon", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Rangoon>>,
    [24] #<ActiveSupport::TimeZone:0x00559539277f80 @name="Bangkok", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Bangkok>>,
    [25] #<ActiveSupport::TimeZone:0x00559539252410 @name="Beijing", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Shanghai>>,
    [26] #<ActiveSupport::TimeZone:0x005595391ab908 @name="Osaka", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Tokyo>>,
    [27] #<ActiveSupport::TimeZone:0x00559539183cc8 @name="Adelaide", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Australia/Adelaide>>,
    [28] #<ActiveSupport::TimeZone:0x005595390e8c78 @name="Brisbane", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Australia/Brisbane>>,
    [29] #<ActiveSupport::TimeZone:0x005595392bb050 @name="Magadan", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Asia/Magadan>>,
    [30] #<ActiveSupport::TimeZone:0x00559539063640 @name="Auckland", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Auckland>>,
    [31] #<ActiveSupport::TimeZone:0x00559539389680 @name="Chatham Is.", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Chatham>>,
    [32] #<ActiveSupport::TimeZone:0x00559538ee2af0 @name="Nuku'alofa", @utc_offset=nil, @tzinfo=#<TZInfo::DataTimezone: Pacific/Tongatapu>>
]
@BigGillyStyle

This comment has been minimized.

Show comment
Hide comment
@BigGillyStyle

BigGillyStyle May 24, 2017

@pixeltrix and @sgringwe
I have filed an issue here: #29210

BigGillyStyle commented May 24, 2017

@pixeltrix and @sgringwe
I have filed an issue here: #29210

@BigGillyStyle

This comment has been minimized.

Show comment
Hide comment
@BigGillyStyle

BigGillyStyle Jul 12, 2017

@sgringwe
Could you share your workaround for getting the us_zones to behavior as before?

BigGillyStyle commented Jul 12, 2017

@sgringwe
Could you share your workaround for getting the us_zones to behavior as before?

@sgringwe

This comment has been minimized.

Show comment
Hide comment
@sgringwe

sgringwe Jul 12, 2017

Contributor

@BigGillyStyle it's basically a copy/paste from old version:

def self.basic_us_zones
    @_basic_us_zones ||= begin
      TZInfo::Country.get('US').zone_identifiers.map do |tz_id|
        name = ActiveSupport::TimeZone::MAPPING.key(tz_id)
        name && ActiveSupport::TimeZone[name]
      end.compact.sort!
    end
  end
Contributor

sgringwe commented Jul 12, 2017

@BigGillyStyle it's basically a copy/paste from old version:

def self.basic_us_zones
    @_basic_us_zones ||= begin
      TZInfo::Country.get('US').zone_identifiers.map do |tz_id|
        name = ActiveSupport::TimeZone::MAPPING.key(tz_id)
        name && ActiveSupport::TimeZone[name]
      end.compact.sort!
    end
  end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment