Class: GreenButtonData::LocalTimeParameters

Inherits:
Entry
  • Object
show all
Includes:
Dst
Defined in:
lib/green-button-data/local_time_parameters.rb

Constant Summary

Constants included from Dst

Dst::BITMASK_DAY_OF_MONTH, Dst::BITMASK_DAY_OF_WEEK, Dst::BITMASK_DST_RULE, Dst::BITMASK_HOUR, Dst::BITMASK_MONTH, Dst::BITMASK_SECOND, Dst::BITSHIFT_DAY_OF_MONTH, Dst::BITSHIFT_DAY_OF_WEEK, Dst::BITSHIFT_DST_RULE, Dst::BITSHIFT_HOUR, Dst::BITSHIFT_MONTH

Instance Attribute Summary collapse

Attributes inherited from Entry

#id, #token, #usage_point_id

Instance Method Summary collapse

Methods included from Dst

#byte_to_dst_datetime, #dst_datetime, #validate_dst_rules

Methods included from Utilities

#attributes_to_hash, #class_from_name, #epoch_to_time, #first_sunday_of, #last_weekday_of, #normalize_epoch, #nth_weekday_of, #parse_datetime, #weekday_offset

Methods inherited from Entry

#initialize

Methods included from Fetchable

included

Constructor Details

This class inherits a constructor from GreenButtonData::Entry

Instance Attribute Details

#dst_offsetObject

Returns the value of attribute dst_offset.



5
6
7
# File 'lib/green-button-data/local_time_parameters.rb', line 5

def dst_offset
  @dst_offset
end

#tz_offsetObject

Returns the value of attribute tz_offset.



5
6
7
# File 'lib/green-button-data/local_time_parameters.rb', line 5

def tz_offset
  @tz_offset
end

Instance Method Details

#dst_ends_at(year = Time.now.year) ⇒ Object



11
12
13
# File 'lib/green-button-data/local_time_parameters.rb', line 11

def dst_ends_at(year = Time.now.year)
  byte_to_dst_datetime(@dst_end_rule, year).to_time
end

#dst_starts_at(year = Time.now.year) ⇒ Object



7
8
9
# File 'lib/green-button-data/local_time_parameters.rb', line 7

def dst_starts_at(year = Time.now.year)
  byte_to_dst_datetime(@dst_start_rule, year).to_time
end

#to_h(year = Time.now.year) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/green-button-data/local_time_parameters.rb', line 19

def to_h(year = Time.now.year)
  {
    dst: {
      starts_at: dst_starts_at(year),
      ends_at: dst_ends_at(year),
      offset: dst_offset
    },
    tz_offset: tz_offset,
    total_offset: total_offset
  }
end

#total_offsetObject



15
16
17
# File 'lib/green-button-data/local_time_parameters.rb', line 15

def total_offset
  @dst_offset + @tz_offset
end