So it seems rails has pretty nice support for timezones, but I’ve run into a requirement that I’m hoping has already been solved and I’m just not seeing it in the api.
I’d like to be able to find a TimeZone based on an offset. The reason being I’m hooking up to an api that gives me back the users time zone as an offset and don’t want to necessarily reinvent the wheel turning that offset into a Rails TimeZone so the rest of the app can use it properly.
Any suggestions? Thanks for the help!
You can get a timezone using the
[]method onActiveSupport::TimeZone. You can either pass a timezone name, hour offset or second offset. For instance:But keep in mind that an offset is not equivalent to a timezone since multiple timezones can be on the same offset on any one day.