Class: GreenButton::Parser::GbLocalTimeParameters
- Inherits:
-
Object
- Object
- GreenButton::Parser::GbLocalTimeParameters
- Includes:
- SAXMachine, Utils::DSTRule
- Defined in:
- lib/ce-greenbutton/elements/gb_local_time_parameters.rb
Overview
a sax-machine mapping for the espi:LocalTimeParameters structure
For example:
local_time_parameters = GbLocalTimeParameters.parse(open(local_time_parameters.xml))
Author: ahmed.seddiq Version: 1.0
Constant Summary collapse
- EDT =
an instance representing the EDT timezone
GbLocalTimeParameters.new(tz_offset: -14400)
Instance Attribute Summary collapse
-
#dst_end_time ⇒ Object
Returns the value of attribute dst_end_time.
-
#dst_start_time ⇒ Object
Returns the value of attribute dst_start_time.
-
#tz_offset ⇒ Object
Returns the value of attribute tz_offset.
Instance Method Summary collapse
-
#local_time(time) ⇒ Object
Converts time to local based on the given time configuration.
Methods included from Utils::DSTRule
Instance Attribute Details
#dst_end_time ⇒ Object
Returns the value of attribute dst_end_time.
21 22 23 |
# File 'lib/ce-greenbutton/elements/gb_local_time_parameters.rb', line 21 def dst_end_time @dst_end_time end |
#dst_start_time ⇒ Object
Returns the value of attribute dst_start_time.
20 21 22 |
# File 'lib/ce-greenbutton/elements/gb_local_time_parameters.rb', line 20 def dst_start_time @dst_start_time end |
#tz_offset ⇒ Object
Returns the value of attribute tz_offset.
22 23 24 |
# File 'lib/ce-greenbutton/elements/gb_local_time_parameters.rb', line 22 def tz_offset @tz_offset end |
Instance Method Details
#local_time(time) ⇒ Object
Converts time to local based on the given time configuration.
The time after applying the rules in the time_config
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ce-greenbutton/elements/gb_local_time_parameters.rb', line 56 def local_time(time) # apply timezone offset time += self.tz_offset # apply dst offset unless @dst_start_time.nil? or @dst_end_time.nil? if Time.now.between?(@dst_start_time, @dst_end_time) time += self.dst_offset end end Time.at(time) end |