How can a method take the current Time.zone and put it into a format that is usable by ActiveSupport::TimeZone[some_zone].parse()?
It seems very strange that Time.zone.to_s returns a string that can not be used with ActiveSupport::TimeZone[zone].parse()
Time.zone.to_s returns "(GMT-08:00) Pacific Time (US & Canada)"
But ActiveSupport::TimeZone["(GMT-08:00) Pacific Time (US & Canada)"] is nil.
ActiveSupport::TimeZone["(GMT-08:00) Pacific Time (US & Canada)"]
# => nil
ActiveSupport::TimeZone["Pacific Time (US & Canada)"]
# => (GMT-08:00) Pacific Time (US & Canada)
Use
Time.zone.name, notTime.zone.to_sAs for how I got this (as requested), I just know the
namemethod exists onTime.zone. If I didn’t know this by heart though, I will check the docs. If it’s not in there as you say (and it is, here), I typically inspect the class/module/object with Pry. Pry is an alternative to irb that lets me do something likels -mon line[2]above prints methods on the object (if you scroll right you’ll seenamelisted there). You can see in[3]I can callnamedirectly on theTime.zoneobject I’m inside of and get the output you’re looking for.