app/controllers/schedules_controller.rb
# partition schdules to each day schedules by its datetime(datetime format)
# schedules are supposed to be already sorted by start_datetime.
# result is array of arrays each of which is [date, [schedules of the date]]
partition schdules to each day schedules by its datetime(datetime format)
schedules are supposed to be already sorted by start_datetime.
result is array of arrays each of which is [date, [schedules of the date]]
partition schdules to each day schedules by its datetime ( datetime format ) schedules are supposed to be already sorted by start_datetime . result is array of arrays each of which is [ date [ schedules of the date ]]
def partition_schedules_per_day(schedules, datetime_span)
    date = datetime_span.first.to_date
    end_date = datetime_span.last.to_date
    result = []
    while date <= end_date do 
      day_sch = schedules.select do |sch| sch.start_datetime.to_date == date end
      day_sch.nil? and day_sch = []
      result << [date, day_sch]
      schedules = schedules[day_sch.length..-1]
      date += 1.day
    end
    result
  end
def partition_schedules_per_day ( schedules , datetime_span ) date = datetime_span . first . to_date end_date = datetime_span . last . to_date result = [ ] while date <= end_date do day_sch = schedules . select do | sch | sch . start_datetime . to_date == date end day_sch . nil? and day_sch = [ ] result << [ date , day_sch ] schedules = schedules [ day_sch . length .. - 1 ] date += 1 . day end result end
partition schdules to each day schedules by its datetime(datetime format)
schedules are supposed to be already sorted by start_datetime.
partition schdules to each day schedules by its datetime ( datetime format ) schedules are supposed to be already sorted by start_datetime .
#      day_sch = [] if day_sch.nil?
schedules
<not_specific>
datetime_span
<not_specific>