How to translate timezone full names to tz abbreviations?

Time.now.zone
# => "UTC"

To use the default Timezone (if set) you can use:

Time.zone.now.zone
# => "CDT"

More info on that: http://api.rubyonrails.org/classes/Time.html#method-c-zone-3D


I looked all over for this answer, and I finally found what I was looking for. I'm leaving the answer here so others might not have to look nearly as long and hard as I had to.

If you have access to ActiveSupport and dealing with TimeZone objects like this:

timezone = ActiveSupport::TimeZone.all[44]

then you can get to the abbreviation this way:

timezone.tzinfo.current_period.abbreviation

For the current time zone:

Time.zone.now.strftime('%Z')

Or for a list of time zones:

ActiveSupport::TimeZone.us_zones.map do |zone|
  Time.now.in_time_zone(zone).strftime('%Z')
end

It works, but it still seems like there should be a better way...