Module: RiCal::CoreExtensions::DateTime::Conversions

Included in:
DateTime
Defined in:
lib/ri_cal/core_extensions/date_time.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#to_dateObject

Converts self to a Ruby Date object; time portion is discarded



38
39
40
# File 'lib/ri_cal/core_extensions/date_time.rb', line 38

def to_date
  ::Date.new(year, month, day)
end

#to_datetimeObject

To be able to keep Times, Dates and DateTimes interchangeable on conversions



44
45
46
# File 'lib/ri_cal/core_extensions/date_time.rb', line 44

def to_datetime
  self
end

#to_overlap_range_startObject Also known as: to_overlap_range_end



26
27
28
# File 'lib/ri_cal/core_extensions/date_time.rb', line 26

def to_overlap_range_start
  self
end

#to_ri_cal_date_time_value(timezone_finder = nil) ⇒ Object Also known as: to_ri_cal_date_or_date_time_value, to_ri_cal_occurrence_list_value

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



11
12
13
14
15
16
# File 'lib/ri_cal/core_extensions/date_time.rb', line 11

def to_ri_cal_date_time_value(timezone_finder = nil) #:nodoc:
  RiCal::PropertyValue::DateTime.new(
       timezone_finder, 
       :value => strftime("%Y%m%dT%H%M%S"), 
       :params => {"TZID" => self.tzid || :default})
end

#to_ri_cal_property_value(timezone_finder = nil) ⇒ Object

Return the natural ri_cal_property for this object



22
23
24
# File 'lib/ri_cal/core_extensions/date_time.rb', line 22

def to_ri_cal_property_value(timezone_finder = nil) #:nodoc:
  to_ri_cal_date_time_value(timezone_finder)
end

#with_floating_timezoneObject

Return a copy of this object which will be interpreted as a floating time.



32
33
34
# File 'lib/ri_cal/core_extensions/date_time.rb', line 32

def with_floating_timezone
  dup.set_tzid(:floating)
end