class RiCal::PropertyValue::Date

RiCal::PropertyValue::CalAddress represents an icalendar Date property value
which is defined in
RFC 2445 section 4.3.4 p 34

Public Instance Methods

+(duration) click to toggle source

Return the sum of the receiver and duration

The parameter other duration should be a RiCal::PropertyValue::Duration

The result will be an RiCal::PropertyValue::DateTime

# File lib/ri_cal/property_value/date.rb, line 139
def +(duration)
  duration.add_to_date_time_value(to_ri_cal_date_time_value)
end
-(other) click to toggle source

Return the difference between the receiver and other

The parameter other should be either a RiCal::PropertyValue::Duration or a RiCal::PropertyValue::DateTime

If other is a Duration, the result will be a DateTime, if it is a DateTime the result will be a Duration

# File lib/ri_cal/property_value/date.rb, line 126
def -(other)
  other.subtract_from_date_time_value(to_ri_cal_date_time_value)
end
day() click to toggle source

Returns the day of the month

# File lib/ri_cal/property_value/date.rb, line 72
def day
  @date_time_value.day
end
for_occurrence(occurrence) click to toggle source
# File lib/ri_cal/property_value/date.rb, line 175
def for_occurrence(occurrence)
  if occurrence.start_of_day?
     occurrence.to_ri_cal_date_value(timezone_finder)
  else
    occurrence.for_parent(timezone_finder)
  end
end
month() click to toggle source

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

# File lib/ri_cal/property_value/date.rb, line 67
def month
  @date_time_value.month
end
ruby_value() click to toggle source

Returns the ruby representation a ::Date

# File lib/ri_cal/property_value/date.rb, line 77
def ruby_value
  @date_time_value.date
end
Also aliased as: to_ri_cal_ruby_value
start_of_day?() click to toggle source
# File lib/ri_cal/property_value/date.rb, line 155
def start_of_day?
  true
end
subtract_from_date_time_value(date_time) click to toggle source
# File lib/ri_cal/property_value/date.rb, line 130
def subtract_from_date_time_value(date_time)
  to_ri_cal_date_time_value.subtract_from_date_time_value(date_time)
end
to_finish_time() click to toggle source
# File lib/ri_cal/property_value/date.rb, line 171
def to_finish_time
  to_ri_cal_date_time_value.end_of_day.to_datetime
end
to_floating_date_time_property() click to toggle source
# File lib/ri_cal/property_value/date.rb, line 159
def to_floating_date_time_property
  PropertyValue::DateTime.new(timezone_finder, :value => @date_time_value.ical_str)
end
to_ri_cal_date_or_date_time_value() click to toggle source

Return the “Natural' property value for the date_property, in this case the date property itself.”

# File lib/ri_cal/property_value/date.rb, line 94
def to_ri_cal_date_or_date_time_value
  self
end
to_ri_cal_date_time_value() click to toggle source

Return an instance of RiCal::PropertyValue::DateTime representing the start of this date

# File lib/ri_cal/property_value/date.rb, line 84
def to_ri_cal_date_time_value
  PropertyValue::DateTime.new(timezone_finder, :value => @date_time_value)
end
to_ri_cal_date_value(timezone_finder = nil) click to toggle source

Return this date property

# File lib/ri_cal/property_value/date.rb, line 89
def to_ri_cal_date_value(timezone_finder = nil)
  self
end
to_ri_cal_ruby_value()
Alias for: ruby_value
to_ri_cal_zulu_date_time() click to toggle source
# File lib/ri_cal/property_value/date.rb, line 24
def to_ri_cal_zulu_date_time
  self.to_ri_cal_date_time_value.to_ri_cal_zulu_date_time
end
to_zulu_occurrence_range_finish_time() click to toggle source
# File lib/ri_cal/property_value/date.rb, line 167
def to_zulu_occurrence_range_finish_time
  to_ri_cal_date_time_value.end_of_day.to_zulu_occurrence_range_finish_time
end
to_zulu_occurrence_range_start_time() click to toggle source
# File lib/ri_cal/property_value/date.rb, line 163
def to_zulu_occurrence_range_start_time
  to_floating_date_time_property.to_zulu_occurrence_range_start_time
end
value() click to toggle source

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

# File lib/ri_cal/property_value/date.rb, line 16
def value
  if @date_time_value
    @date_time_value.ical_date_str
  else
    nil
  end
end
value=(val) click to toggle source

Set the value of the property to val

val may be either:

# File lib/ri_cal/property_value/date.rb, line 36
def value=(val)
  case val
  when nil
    @date_time_value = nil
  when String
    @date_time_value = FastDateTime.from_date_time(::DateTime.parse(::DateTime.parse(val).strftime("%Y%m%d")))
  when ::Time, ::Date, ::DateTime
    @date_time_value = FastDateTime.from_date_time(::DateTime.parse(val.strftime("%Y%m%d")))
  when FastDateTime
    @date_time_value = val
  end
end
year() click to toggle source

Returns the year (including the century)

# File lib/ri_cal/property_value/date.rb, line 62
def year
  @date_time_value.year
end