Module: RiCal::CoreExtensions::Date::Conversions

Included in:
Date
Defined in:
lib/ri_cal/core_extensions/date.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#to_dateObject

A method to keep Time, Date and DateTime instances interchangeable on conversions. In this case, it simply returns self.



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

def to_date
  self
end

#to_datetimeObject

Converts a Date instance to a DateTime, where the time is set to the beginning of the day and UTC offset is set to 0.

Examples

date = Date.new(2007, 11, 10)  # => Sat, 10 Nov 2007

date.to_datetime               # => Sat, 10 Nov 2007 00:00:00 0000


50
51
52
# File 'lib/ri_cal/core_extensions/date.rb', line 50

def to_datetime
  ::DateTime.civil(year, month, day, 0, 0, 0, 0)
end

#to_overlap_range_endObject



31
32
33
# File 'lib/ri_cal/core_extensions/date.rb', line 31

def to_overlap_range_end
  to_ri_cal_date_time_value.end_of_day.to_datetime
end

#to_overlap_range_startObject



27
28
29
# File 'lib/ri_cal/core_extensions/date.rb', line 27

def to_overlap_range_start
  to_datetime
end

#to_ri_cal_date_time_value(timezone_finder = nil) ⇒ Object

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



10
11
12
# File 'lib/ri_cal/core_extensions/date.rb', line 10

def to_ri_cal_date_time_value(timezone_finder = nil)
  RiCal::PropertyValue::DateTime.new(timezone_finder, :value => self)
end

#to_ri_cal_date_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::Date representing the receiver



15
16
17
# File 'lib/ri_cal/core_extensions/date.rb', line 15

def to_ri_cal_date_value(timezone_finder = nil)
  RiCal::PropertyValue::Date.new(timezone_finder, :value => self)
end

#to_ri_cal_property_value(timezone_finder = nil) ⇒ Object

Return the natural ri_cal_property for this object



23
24
25
# File 'lib/ri_cal/core_extensions/date.rb', line 23

def to_ri_cal_property_value(timezone_finder = nil)
  to_ri_cal_date_value(timezone_finder)
end