docs: def dates_range(event, format=""):
      """
      :param event: An Event 
      :param format: A |-separated string specifying:
          date_format - a format specifier
          separator - the string to join the start and end dates with, if they're 
              different
          no_dates_text - text to return if the event has no occurrences, 
              default ''
          from_text - text to prepend if the event never ends (the 'last' date is 
              None)
      :return: text describing the date range for the event. If human dates are 
      given, use that, otherwise, use the first and last occurrences for an event.
  
      If the first and last dates have year or year and month in common, 
      the format string for the first date is modified to exclude those items.
      
      If the first and last dates are equal, only the first date is used (ie with
      no range)
  
      You can override this behaviour by specifying additional formats with
      "_SAME_YEAR" and "_SAME_YEAR_SAME_MONTH" appended to the name.
      """
  
      # TODO: factor out a more general filter that accepts 1-2 dates and
      # renders the range.
  
      # resolve arguments
      date_format = settings.DATE_FORMAT # Django's default
      separator = "&nbsp;&ndash; "
      no_dates_text = ''
      from_text = "from "
      arg_list = [arg.strip() for arg in format.split('|')]
      if arg_list:
          date_format = arg_list[0]
          try:
              separator = arg_list[1]
              no_dates_text = arg_list[2]
              from_text = arg_list[3]
              ended_text = arg_list[4]
          except IndexError:
              pass
  
      if event.human_dates:
          return event.human_dates.strip()
  
      # Get the dates from the occurrence
      first, last = event.get_occurrences_range()
      start, end = None, None
      if first:
          start = first.local_start
      if last:
          end = last.local_end
  
      # figure out to what extent the dates differ
      if start and end:
          first_date_format = get_format(date_format, use_l10n=True)
          if start.year == end.year:
              # use a first_date_format without the year
              first_date_format = _format_with_same_year(date_format)
              if start.month == end.month:
                  # remove month spec from first_date_format
                  first_date_format = _format_with_same_year_and_month(date_format)
                  if start.day == end.day:
                      # the two dates are equal, just return one date.
                      return mark_safe(datefilter(start, date_format))
  
          return mark_safe('%s%s%s' % (
              datefilter(start, first_date_format),
              separator,
              datefilter(end, date_format)
          ))
  
      elif start and not end:
          return '%s%s' % (from_text, datefilter(start, date_format))
      elif not (start or end):
          return no_dates_text
      else:
          raise AssertionError("Got a date range that has a last date but no first date")