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


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

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