Class: Zmanim::Util::TimeZoneConverter
- Inherits:
-
Object
- Object
- Zmanim::Util::TimeZoneConverter
- Defined in:
- lib/zmanim/util/time_zone_converter.rb
Instance Attribute Summary collapse
-
#time_zone ⇒ Object
readonly
Returns the value of attribute time_zone.
Instance Method Summary collapse
-
#initialize(time_zone) ⇒ TimeZoneConverter
constructor
A new instance of TimeZoneConverter.
-
#modify_offset(time) ⇒ Object
Adjust a DateTime for the provided time zone.
-
#offset_at(time) ⇒ Object
offset in effect for time zone at the given time (in hours).
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_zone ⇒ Object (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 |