How do I get the abbreviation from the timezone instead of the clock offset from strftime?

I know there are many timezones that use the same offsets from UTC / GMT. When using strftime ('% Z'), it returns the offset in hours / minutes.

Does anyone know of an easy way to get the timezone as a string with 3 characters of the timezone, for example. +0100 => CET

I have defined my own date format in my time_formats.rb initializer

Time::DATE_FORMATS[:friendly_datetime] = '%A, %-d %B %Y at %H:%M %Z'

This gives: Sunday, 11 January 2015 at 20:00 +0100

I would like% Z (+0100) to be CET. I was thinking about making my own hash translation and using proc in my custom time format. I kind of hoped there was a built-in way, or maybe a gem that I don't know about.

+3


source to share





All Articles