module TimeKeeper::TimeRangeManipulation
Public Class Methods
split_time_range_by_day(range)
click to toggle source
# File lib/time_keeper/time_range_manipulation.rb, line 3 def split_time_range_by_day(range) return [] if range.blank? if range.first.to_date < range.last.to_date out = [] current = range.first while current.to_i <= range.last.to_i eod = current.end_of_day eod = range.last if current.to_date == range.last.to_date out << (current .. eod) current = eod + 1.second end out else [range] end end
Private Instance Methods
split_time_range_by_day(range)
click to toggle source
# File lib/time_keeper/time_range_manipulation.rb, line 3 def split_time_range_by_day(range) return [] if range.blank? if range.first.to_date < range.last.to_date out = [] current = range.first while current.to_i <= range.last.to_i eod = current.end_of_day eod = range.last if current.to_date == range.last.to_date out << (current .. eod) current = eod + 1.second end out else [range] end end