I'm running in Rails 3.2 and I can't figure out a nice way to parse a time that's given to me in an arbitrary time zone.
As an example this is the format I'm given in separate keys
{
"start_date"=>"2013-04-24 13:00:00",
"timezone"=>"America/Los_Angeles",
"timezone_offset"=>"GMT-0700",
...
}
This question comes very close to answering it with:
time = ActiveSupport::TimeZone.new('UTC').parse('2010-02-05 01:00:01')
The problem is when I put in "America/Los_Angeles" as an argumento to Timezone.new
, it spits out a timezone of GMT-8, I think due to DST changing. On the other hand, the data I receive defines the timezone offset from GMT. So for my example, the desired output is a timezone of GMT-7.
Is there any way to get the timezone if I know the gmt offset, instead of using the name of the timezone?