Parent

RiCal::PropertyValue::DateTime

 RiCal::PropertyValue::CalAddress represents an icalendar CalAddress property value
 which is defined in RFC 2445 section 4.3.5 pp 35-37

Public Class Methods

default_tzid=(tzid) click to toggle source

Set the default tzid to be used when instantiating an instance from a ruby object see RiCal::PropertyValue::DateTime.from_time

The parameter tzid is a string value to be used for the default tzid, a value of :floating will cause values with NO timezone to be produced, which will be interpreted by iCalendar as floating times i.e. they are interpreted in the timezone of each client. Floating times are typically used to represent events which are ‘repeated’ in the various time zones, like the first hour of the year.

# File lib/ri_cal/property_value/date_time.rb, line 50
      def self.default_tzid=(tzid)
        @default_tzid = tzid
      end
time_and_parameters(object) click to toggle source

Extract the time and timezone identifier from an object used to set the value of a DATETIME property.

If the object is a string it should be of the form [TZID=identifier:]

Otherwise determine if the object acts like an activesupport enhanced time, and extract its timezone idenfifier if it has one.

# File lib/ri_cal/property_value/date_time.rb, line 111
      def self.time_and_parameters(object)
        parameters = {}
        if ::String === object
          object, parameters = self.time_and_parameters_from_string(object)
        else
          identifier = object.tzid rescue nil
          parameters["TZID"] = identifier if identifier
        end
        [object, parameters]
      end

Public Instance Methods

<=>(other) click to toggle source

Compare the receiver with another object which must respond to the to_datetime message The comparison is done using the Ruby DateTime representations of the two objects

# File lib/ri_cal/property_value/date_time.rb, line 177
      def <=>(other)
       other.cmp_fast_date_time_value(@date_time_value)
      end
==(other) click to toggle source

Determine if the receiver and another object are equivalent RiCal::PropertyValue::DateTime instances

# File lib/ri_cal/property_value/date_time.rb, line 220
      def ==(other)
        if self.class === other
          self.value == other.value && self.visible_params == other.visible_params && self.tzid == other.tzid
        else
          super
        end
      end
cmp_fast_date_time_value(other) click to toggle source

(Not documented)

# File lib/ri_cal/property_value/date_time.rb, line 181
      def cmp_fast_date_time_value(other)
        other <=> @date_time_value
      end
day() click to toggle source

Return the day of the month

# File lib/ri_cal/property_value/date_time.rb, line 244
      def day
        @date_time_value.day
      end
Also aliased as: mday
days_in_month() click to toggle source

Return the number of days in the month containing the receiver

# File lib/ri_cal/property_value/date_time.rb, line 215
      def days_in_month
        @date_time_value.days_in_month
      end
for_occurrence(occurrence) click to toggle source

(Not documented)

# File lib/ri_cal/property_value/date_time.rb, line 346
      def for_occurrence(occurrence)
        occurrence.to_ri_cal_date_time_value(timezone_finder)
      end
hour() click to toggle source

Return the hour

# File lib/ri_cal/property_value/date_time.rb, line 256
      def hour
        @date_time_value.hour
      end
in_same_month_as?(other) click to toggle source

Determine if the receiver and other are in the same month

# File lib/ri_cal/property_value/date_time.rb, line 186
      def in_same_month_as?(other)
        [other.year, other.month] == [year, month]
      end
mday() click to toggle source

Alias for day

min() click to toggle source

Return the minute

# File lib/ri_cal/property_value/date_time.rb, line 261
      def min
        @date_time_value.min
      end
month() click to toggle source

Return the month of the year (1..12)

# File lib/ri_cal/property_value/date_time.rb, line 239
      def month
        @date_time_value.month
      end
params() click to toggle source

Return a Hash representing this properties parameters

# File lib/ri_cal/property_value/date_time.rb, line 164
      def params
        result = @params.dup
        case tzid
        when :floating, nil, "UTC"
          result.delete('TZID')
        else
          result['TZID'] = tzid
        end
        result
      end
ruby_value() click to toggle source

Returns a ruby DateTime object representing the receiver.

# File lib/ri_cal/property_value/date_time.rb, line 300
      def ruby_value
        if has_valid_tzinfo_tzid? && RiCal::TimeWithZone && tz_info_source?
          RiCal::TimeWithZone.new(utc.to_datetime, ::Time.__send__(:get_zone, @tzid))
        else
          ::DateTime.civil(year, month, day, hour, min, sec, rational_tz_offset).set_tzid(@tzid)
        end
      end
Also aliased as: to_finish_time
sec() click to toggle source

Return the second

# File lib/ri_cal/property_value/date_time.rb, line 266
      def sec
        @date_time_value.sec
      end
start_of_day?() click to toggle source

(Not documented)

# File lib/ri_cal/property_value/date_time.rb, line 342
      def start_of_day?
        [hour, min, sec] == [0,0,0]
      end
to_finish_time() click to toggle source

Alias for ruby_value

to_ri_cal_date_time_value(timezone=nil) click to toggle source

Return an RiCal::PropertyValue::DateTime representing the receiver.

# File lib/ri_cal/property_value/date_time.rb, line 272
      def to_ri_cal_date_time_value(timezone=nil)
        for_parent(timezone)
      end
to_ri_cal_date_value(timezone_finder=nil) click to toggle source

Return a Date property for this DateTime

# File lib/ri_cal/property_value/date_time.rb, line 290
      def to_ri_cal_date_value(timezone_finder=nil)
        PropertyValue::Date.new(timezone_finder, :value => @date_time_value.ical_date_str)
      end
to_zulu_occurrence_range_finish_time() click to toggle source

If a time is floating, then the utc of it’s start time may actually be as early as 12 hours later if the occurrence is being viewed in a time zone just east of the International Date Line

# File lib/ri_cal/property_value/date_time.rb, line 330
      def to_zulu_occurrence_range_finish_time
        if floating?
          utc.advance(:hours => 12).to_datetime
        else
          to_zulu_time
        end
      end
to_zulu_occurrence_range_start_time() click to toggle source

If a time is floating, then the utc of it’s start time may actually be as early as 12 hours earlier if the occurrence is being viewed in a time zone just west of the International Date Line

# File lib/ri_cal/property_value/date_time.rb, line 318
      def to_zulu_occurrence_range_start_time
        if floating?
          @date_time_value.advance(:hours => -12, :offset => 0).to_datetime
        else
          to_zulu_time
        end
      end
to_zulu_time() click to toggle source

(Not documented)

# File lib/ri_cal/property_value/date_time.rb, line 311
      def to_zulu_time
        utc.to_datetime
      end
value() click to toggle source

Returns the value of the receiver as an RFC 2445 iCalendar string

# File lib/ri_cal/property_value/date_time.rb, line 67
      def value
        if @date_time_value
          "#{@date_time_value.ical_str}#{tzid == "UTC" ? "Z" : ""}"
        else
          nil
        end
      end
wday() click to toggle source

Return the day of the week

# File lib/ri_cal/property_value/date_time.rb, line 251
      def wday
        @date_time_value.wday
      end
with_date_time_value(date_time_value) click to toggle source

(Not documented)

# File lib/ri_cal/property_value/date_time.rb, line 190
      def with_date_time_value(date_time_value)
        PropertyValue::DateTime.new(
          timezone_finder,
          :value => date_time_value,
          :params => (params),
          :tzid => tzid
        )
      end
year() click to toggle source

Return the year (including the century)

# File lib/ri_cal/property_value/date_time.rb, line 234
      def year
        @date_time_value.year
      end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.