Class: TZInfo::AnnualRules Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/tzinfo/annual_rules.rb |
Overview
A set of rules that define when transitions occur in time zones with annually occurring daylight savings time.
Class Method Summary
-
.new(std_offset, dst_offset, dst_start_rule, dst_end_rule) ⇒ AnnualRules
constructor
Internal use only
Initializes a new
AnnualRules
instance.
Instance Attribute Summary
- #dst_end_rule ⇒ TransitionRule readonly Internal use only
- #dst_offset ⇒ TimezoneOffset readonly Internal use only
- #dst_start_rule ⇒ TransitionRule readonly Internal use only
- #std_offset ⇒ TimezoneOffset readonly Internal use only
Instance Method Summary
-
#transitions(year) ⇒ Array<TimezoneTransition>
Internal use only
Returns the transitions between standard and daylight savings time for a given year.
-
#apply_rule(rule, from_offset, to_offset, year) ⇒ TimezoneTransition
private
Internal use only
Applies a given rule between offsets on a year.
Instance Attribute Details
#dst_end_rule ⇒ TransitionRule (readonly)
# File 'lib/tzinfo/annual_rules.rb', line 24
attr_reader :dst_end_rule
#dst_offset ⇒ TimezoneOffset (readonly)
# File 'lib/tzinfo/annual_rules.rb', line 16
attr_reader :dst_offset
#dst_start_rule ⇒ TransitionRule (readonly)
# File 'lib/tzinfo/annual_rules.rb', line 20
attr_reader :dst_start_rule
#std_offset ⇒ TimezoneOffset (readonly)
# File 'lib/tzinfo/annual_rules.rb', line 12
attr_reader :std_offset
Instance Method Details
#apply_rule(rule, from_offset, to_offset, year) ⇒ TimezoneTransition (private)
Applies a given rule between offsets on a year.
# File 'lib/tzinfo/annual_rules.rb', line 65
def apply_rule(rule, from_offset, to_offset, year) at = rule.at(from_offset, year) TimezoneTransition.new(to_offset, from_offset, at.value) end
#transitions(year) ⇒ Array
<TimezoneTransition>
Returns the transitions between standard and daylight savings time for a given year. The results are ordered by time of occurrence (earliest to latest).
# File 'lib/tzinfo/annual_rules.rb', line 49
def transitions(year) start_dst = apply_rule(@dst_start_rule, @std_offset, @dst_offset, year) end_dst = apply_rule(@dst_end_rule, @dst_offset, @std_offset, year) end_dst. < start_dst. ? [end_dst, start_dst] : [start_dst, end_dst] end