Class Icalendar::Timezone
In: lib/icalendar/component/timezone.rb
Parent: Component

A Timezone is unambiguously defined by the set of time measurement rules determined by the governing body for a given geographic area. These rules describe at a minimum the base offset from UTC for the time zone, often referred to as the Standard Time offset. Many locations adjust their Standard Time forward or backward by one hour, in order to accommodate seasonal changes in number of daylight hours, often referred to as Daylight Saving Time. Some locations adjust their time by a fraction of an hour. Standard Time is also known as Winter Time. Daylight Saving Time is also known as Advanced Time, Summer Time, or Legal Time in certain countries. The following table shows the changes in time zone rules in effect for New York City starting from 1967. Each line represents a description or rule for a particular observance.

Methods

add_component   daylight   new   standard   to_ical  

Attributes

comment    Multi-properties
comment    Multi-properties
comments    Multi-properties
created   
daylight   
dtstart    Single properties
last_modified   
rdate   
recurrence_date   
recurrence_dates   
recurrence_rule   
recurrence_rules   
rrule   
sequence   
standard   
start    Single properties
timestamp   
timezone_id   
timezone_name   
timezone_offset_from   
timezone_offset_to   
tzid   
tzname   
tzoffsetfrom   
tzoffsetto   

Public Class methods

[Source]

# File lib/icalendar/component/timezone.rb, line 62
    def initialize(name = "VTIMEZONE")
      super(name)
    end

Public Instance methods

Define a custom add component method because standard and daylight are the only components that can occur just once with their parent.

[Source]

# File lib/icalendar/component/timezone.rb, line 44
    def add_component(component)
      key = component.class.to_s.downcase.gsub('icalendar::','').to_sym
      @components[key] = component
    end

[Source]

# File lib/icalendar/component/timezone.rb, line 76
    def daylight(&block)
      e = Daylight.new
      self.add_component e

      e.instance_eval &block if block

      e
    end

Allow block syntax for declaration of standard and daylight components of timezone

[Source]

# File lib/icalendar/component/timezone.rb, line 67
    def standard(&block)
      e = Standard.new
      self.add_component e

      e.instance_eval &block if block

      e
    end

Also need a custom to_ical because typically it iterates over an array of components.

[Source]

# File lib/icalendar/component/timezone.rb, line 51
    def to_ical
      print_component do
      s = ""
        @components.each_value do |comp|
          s << comp.to_ical
        end
      s
      end
    end

[Validate]