class TZInfo::TimezonePeriod

def build_timezone(timezone, transition)

def build_timezone(timezone, transition)
  timezone.tap do |tz|
    tz.tzname = transition.offset_abbreviation
    tz.tzoffsetfrom = transition.offset_from
    tz.tzoffsetto = transition.offset_to
    tz.dtstart = transition.dtstart
    yield tz
  end
end

def daylight

for standard TZ, use the following period (starting from the end_transition).
For DST, use the start_transition,
def daylight
  transition = dst? ? start_transition : end_transition
  day = Icalendar::Timezone::Daylight.new
  build_timezone(day, transition) do |tz|
    # rrule should not be set for the current [==DST/daylight] period
    # if there is no recurrence rule for the end transition
    if !dst? || !end_transition.nil?
      tz.rrule = transition.rrule
    end
  end
end

def single

def single
  Icalendar::Timezone::Standard.new.tap do |std|
    std.tzname = abbreviation.to_s
    std.tzoffsetfrom = offset.ical_offset
    std.tzoffsetto = offset.ical_offset
    std.dtstart = DateTime.new(1970).strftime '%Y%m%dT%H%M%S'
  end
end

def standard

for DST, use the following period, (starting from the end_transition)
For standard TZ, use the start_transition,
def standard
  transition = dst? ? end_transition : start_transition
  std = Icalendar::Timezone::Standard.new
  build_timezone(std, transition) do |tz|
    if dst? || !end_transition.nil?
      tz.rrule = transition.rrule
    end
  end
end