Forum: Ruby on Rails Timezone abbreviation question

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
5e75f4b81923cd04a5c8fffa290be92e?d=identicon&s=25 Carl Johnson (carlivar)
on 2007-01-24 21:38
Is it possible to get timezone abbreviations using the TimeZone or
TzinfoTimezone classes? Even after converting UTC to localtime it still
reports the timezone abbreviation as UTC.


>> @tz = TzinfoTimezone.us_zones[2]
=> #<TzinfoTimezone:0x30868a0 @utc_offset=-28800, @name="Pacific Time
(US & Canada)">
=> Wed Jan 24 12:36:56 UTC 2007
=> "UTC"

It seems to me that the timezone abbreviation (%Z) should be "PST" in
this case.
5e75f4b81923cd04a5c8fffa290be92e?d=identicon&s=25 Carl Johnson (carlivar)
on 2007-01-25 00:10
Sorry about the reply-to-myself, but I found the answer.

The tzinfo gem has its own strftime method which returns the correct
local timezone abbreviation for %Z. TzinfoTimezone plugin does not wrap
this method. It was very simple to add to the plugin:

  def strftime(string,
    tzinfo.strftime(string, time)

I'm sending this to the author as well.
This topic is locked and can not be replied to.