©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
RiCal::PropertyValue::CalAddress represents an icalendar CalAddress property value which is defined in RFC 2445 section 4.3.5 pp 35-37
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
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 119 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
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 185 def <=>(other) other.cmp_fast_date_time_value(@date_time_value) end
Determine if the receiver and another object are equivalent RiCal::PropertyValue::DateTime instances
# File lib/ri_cal/property_value/date_time.rb, line 228 def ==(other) if self.class === other self.value == other.value && self.visible_params == other.visible_params && self.tzid == other.tzid else super end end
# File lib/ri_cal/property_value/date_time.rb, line 189 def cmp_fast_date_time_value(other) other <=> @date_time_value end
Return the day of the month
# File lib/ri_cal/property_value/date_time.rb, line 252 def day @date_time_value.day end
Return the number of days in the month containing the receiver
# File lib/ri_cal/property_value/date_time.rb, line 223 def days_in_month @date_time_value.days_in_month end
# File lib/ri_cal/property_value/date_time.rb, line 354 def for_occurrence(occurrence) occurrence.to_ri_cal_date_time_value(timezone_finder) end
Return the hour
# File lib/ri_cal/property_value/date_time.rb, line 264 def hour @date_time_value.hour end
Determine if the receiver and other are in the same month
# File lib/ri_cal/property_value/date_time.rb, line 194 def in_same_month_as?(other) [other.year, other.month] == [year, month] end
Return the minute
# File lib/ri_cal/property_value/date_time.rb, line 269 def min @date_time_value.min end
Return the month of the year (1..12)
# File lib/ri_cal/property_value/date_time.rb, line 247 def month @date_time_value.month end
Return a Hash representing this properties parameters
# File lib/ri_cal/property_value/date_time.rb, line 172 def params result = @params.dup case tzid when :floating, nil, "UTC" result.delete('TZID') else result['TZID'] = tzid end result end
Returns a ruby DateTime object representing the receiver.
# File lib/ri_cal/property_value/date_time.rb, line 308 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
Return the second
# File lib/ri_cal/property_value/date_time.rb, line 274 def sec @date_time_value.sec end
# File lib/ri_cal/property_value/date_time.rb, line 350 def start_of_day? [hour, min, sec] == [0,0,0] end
Return an RiCal::PropertyValue::DateTime representing the receiver.
# File lib/ri_cal/property_value/date_time.rb, line 280 def to_ri_cal_date_time_value(timezone=nil) for_parent(timezone) end
# File lib/ri_cal/property_value/date_time.rb, line 75 def to_ri_cal_zulu_date_time ZuluDateTime.new(nil, :value => self.utc.fast_date_tme) end
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 338 def to_zulu_occurrence_range_finish_time if floating? utc.advance(:hours => 12).to_datetime else to_zulu_time end end
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 326 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
# File lib/ri_cal/property_value/date_time.rb, line 319 def to_zulu_time utc.to_datetime end
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
Return the day of the week
# File lib/ri_cal/property_value/date_time.rb, line 259 def wday @date_time_value.wday end
Generated with the Darkfish Rdoc Generator 2.