class TZInfo::TimezonePeriod

Public Instance Methods

daylight() click to toggle source

For DST, use the start_transition, for standard TZ, use the following period (starting from the end_transition).

# File lib/icalendar/tzinfo.rb, line 136
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
single() click to toggle source
# File lib/icalendar/tzinfo.rb, line 160
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
standard() click to toggle source

For standard TZ, use the start_transition, for DST, use the following period, (starting from the end_transition)

# File lib/icalendar/tzinfo.rb, line 150
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

Private Instance Methods

build_timezone(timezone, transition) { |tz| ... } click to toggle source
# File lib/icalendar/tzinfo.rb, line 170
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