module ActiveSupport::CoreExtensions::Time::Zones
def self.included(base) #:nodoc:
def self.included(base) #:nodoc: base.extend(ClassMethods) if base == ::Time # i.e., don't include class methods in DateTime end
def in_time_zone(zone = ::Time.zone)
and the conversion will be based on that zone instead of Time.zone.
You can also pass in a TimeZone instance or string that identifies a TimeZone as an argument,
instead of the operating system's time zone.
This method is similar to Time#localtime, except that it uses Time.zone as the local zone
Time.utc(2000).in_time_zone # => Fri, 31 Dec 1999 14:00:00 HST -10:00
Time.zone = 'Hawaii' # => 'Hawaii'
Returns the simultaneous time in Time.zone.
def in_time_zone(zone = ::Time.zone) ActiveSupport::TimeWithZone.new(utc? ? self : getutc, ::Time.__send__(:get_zone, zone)) end