'Adds a date-based facet on a field.'

def add_date_facet(self, field, start_date, end_date, gap_by, gap_amount=1):

    from haystack import connections
    if (gap_by not in VALID_GAPS):
        raise FacetingError((u"The    gap_by    ('%s')    must    be    one    of    the    following:    %s." % (gap_by, u',    '.join(VALID_GAPS))))
    details = {u'start_date': start_date, u'end_date': end_date, u'gap_by': gap_by, u'gap_amount': gap_amount}
    self.date_facets[connections[self._using].get_unified_index().get_facet_fieldname(field)] = details
