Module: TimeKeeper::TimeRangeManipulation
- Defined in:
- lib/time_keeper/time_range_manipulation.rb
Class Method Summary collapse
Class Method Details
.split_time_range_by_day(range) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# 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 |