I have some lines of code in my Ruby script that gets the current date (mine is in GMT) and converts it to ET (Eastern Time).
I have this code in my Ruby script for that:
# get current time and date in ET
my_offset = 3600 * -5 # US Eastern
# find the zone with that offset
zone_name = ActiveSupport::TimeZone::MAPPING.keys.find do |name|
ActiveSupport::TimeZone[name].utc_offset == my_offset
end
zone = ActiveSupport::TimeZone[zone_name]
time_locally = Time.now
time_in_zone = zone.at(time_locally)
The problem is it gives an error here (well, on this line): zone_name = ActiveSupport::TimeZone::MAPPING.keys.find do |name|
: uninitialized constant ActiveSupport::TimeZone (NameError)
Anyone know what's wrong? I obtained this code segment from Stack Overflow, here.