Class: RubyChartEngine::Input::Timezone
- Inherits:
-
Object
- Object
- RubyChartEngine::Input::Timezone
- Defined in:
- lib/ruby_chart_engine/input/timezone.rb
Instance Attribute Summary collapse
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#timezone ⇒ Object
readonly
Returns the value of attribute timezone.
Instance Method Summary collapse
-
#initialize(timezone, datetime = nil) ⇒ Timezone
constructor
Parse timezone from various formats: - TZInfo timezone identifier: “America/Los_Angeles” - UTC offset: “+05:30” or -8 - TZInfo::Timezone object.
-
#offset_hours ⇒ Object
Get offset in hours.
Constructor Details
#initialize(timezone, datetime = nil) ⇒ Timezone
Parse timezone from various formats:
-
TZInfo timezone identifier: “America/Los_Angeles”
-
UTC offset: “+05:30” or -8
-
TZInfo::Timezone object
12 13 14 15 16 |
# File 'lib/ruby_chart_engine/input/timezone.rb', line 12 def initialize(timezone, datetime = nil) @timezone = parse_timezone(timezone) @datetime = datetime @offset = calculate_offset end |
Instance Attribute Details
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
6 7 8 |
# File 'lib/ruby_chart_engine/input/timezone.rb', line 6 def offset @offset end |
#timezone ⇒ Object (readonly)
Returns the value of attribute timezone.
6 7 8 |
# File 'lib/ruby_chart_engine/input/timezone.rb', line 6 def timezone @timezone end |
Instance Method Details
#offset_hours ⇒ Object
Get offset in hours
19 20 21 |
# File 'lib/ruby_chart_engine/input/timezone.rb', line 19 def offset_hours @offset / 3600.0 end |