module EventsHelper
  def event_human_date(event, date_format = "%A %e %B %Y", time_format = "%kh%M")

    if event.entire_day?
      if event.stop_date?
        if event.start_at.strftime('%d/%m/%Y') == event.stop_at.strftime('%d/%m/%Y')
          "le #{l(event.start_at, :format => date_format)}"
        else
          "du #{l(event.start_at, :format => date_format)} au #{l(event.stop_at, :format => date_format)}"
        end
      else
        "le #{l(event.start_at, :format => date_format)}"
      end
    else
      if event.stop_date?
        if event.start_at.strftime('%d/%m/%Y') == event.stop_at.strftime('%d/%m/%Y')
          "le #{l(event.start_at, :format => date_format)} de #{l(event.start_at, :format => time_format)} à #{l(event.stop_at, :format => time_format)} "
        else
          "du #{l(event.start_at, :format => date_format)} à #{l(event.start_at, :format => time_format)} au #{l(event.stop_at, :format => date_format)} à #{l(event.stop_at, :format => time_format)} "
        end
      else
        "le #{l(event.start_at, :format => date_format)} à #{l(event.start_at, :format => time_format)}"
      end
    end

  end
end
