Is there a way to use those fancy time helper methods in specific time zones without doing this?
Time.use_zone(Time.zone.name) { 1.week.ago }
What class(es) should I add a in_zone method to so I can do the following without causing too much confusion?
1.week.ago.in_zone(Time.zone.name)
Or is this already built in? I’m wondering because I use Time.zone.now everywhere and would like a simpler way of doing it on those other cases.
Rails has a method called
in_time_zonewhich does this for you. It works on anyTime,DateorActiveSupport::TimeWithZoneobject..You can get a list of all the available time zones by running: