Class: Zmanim::Util::TimeZoneConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/zmanim/util/time_zone_converter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time_zone) ⇒ TimeZoneConverter

Returns a new instance of TimeZoneConverter.



5
6
7
# File 'lib/zmanim/util/time_zone_converter.rb', line 5

def initialize(time_zone)
  @time_zone = time_zone
end

Instance Attribute Details

#time_zoneObject (readonly)

Returns the value of attribute time_zone.



3
4
5
# File 'lib/zmanim/util/time_zone_converter.rb', line 3

def time_zone
  @time_zone
end

Instance Method Details

#modify_offset(time) ⇒ Object

Adjust a DateTime for the provided time zone



10
11
12
13
# File 'lib/zmanim/util/time_zone_converter.rb', line 10

def modify_offset(time)
  offset = offset_at(time)
  time.new_offset(offset/24)
end

#offset_at(time) ⇒ Object

offset in effect for time zone at the given time (in hours)



16
17
18
# File 'lib/zmanim/util/time_zone_converter.rb', line 16

def offset_at(time)
  time_zone.period_for_utc(time.new_offset(0)).utc_total_offset / (60 * 60).to_f
end