class Date
Public Class Methods
months_between(date1, date2)
click to toggle source
return array with one entry for each month between date1 and date2 (inclusive)
# File lib/date_helper.rb, line 10 def self.months_between(date1, date2) months = [] if date2 < date1 start_date = Date.civil(date2.year, date2.month, 1) end_date = Date.civil(date1.year, date1.month, 1) else start_date = Date.civil(date1.year, date1.month, 1) end_date = Date.civil(date2.year, date2.month, 1) end while (start_date < end_date) months << start_date start_date = start_date >>1 end months << end_date end
utc_times(dates)
click to toggle source
# File lib/date_helper.rb, line 29 def self.utc_times(dates) result = Array.new for date in dates result << date.to_utc_time end result end
Public Instance Methods
to_utc_time()
click to toggle source
return a Time object at 00:00:00 UTC on the given Date
# File lib/date_helper.rb, line 39 def to_utc_time Time.utc(self.year,self.month,self.day) end