Class: TZInfo::Timezone

Inherits:
Object
  • Object
show all
Defined in:
lib/icalendar/tzinfo.rb

Instance Method Summary collapse

Instance Method Details

#ical_timezone(date, dst = Timezone.default_dst) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/icalendar/tzinfo.rb', line 96

def ical_timezone(date, dst = Timezone.default_dst)
  period = period_for_local(date, dst)
  timezone = Icalendar::Timezone.new
  timezone.tzid = identifier
  if period.start_transition.nil?
    timezone.add_component period.single
  elsif period.end_transition.nil?
    timezone.add_component period.dst? ? period.daylight : period.standard
  else
    timezone.add_component period.daylight
    timezone.add_component period.standard
  end
  timezone
end