app/models/record.rb
# Return an array of [start time, end time, record] split over multiple days or over the range
Return an array of [start time, end time, record] split over multiple days or over the range
Return an array of [ start time end time record ] split over multiple days or over the range
def split(range = nil)
    if self.record_category and self.activity?
      entry_end = self.end_timestamp || Time.now
      time = range ? [self.timestamp, range.begin.midnight.in_time_zone].max : self.timestamp
      end_time = range ? [entry_end, range.end.midnight.in_time_zone].min : entry_end
      list = Array.new
      while time < end_time
        new_end = [entry_end, (time + 1.day).midnight.in_time_zone].min
        list << [time, new_end, self]
        time = new_end
      end
    else
      return [self.timestamp, nil, self]
    end
    list
  end
def split ( range = nil ) if self . record_category and self . activity? entry_end = self . end_timestamp || Time . now time = range ? [ self . timestamp , range . begin . midnight . in_time_zone ] . max : self . timestamp end_time = range ? [ entry_end , range . end . midnight . in_time_zone ] . min : entry_end list = Array . new while time < end_time new_end = [ entry_end , ( time + 1 . day ) . midnight . in_time_zone ] . min list << [ time , new_end , self ] time = new_end end else return [ self . timestamp , nil , self ] end list end
Return an array of [start time, end time, record] split over multiple days or over the range
Return an array of [ start time end time record ] split over multiple days or over the range
range
<not_specific>