code: def get_headers(self, date_headers, from_date, to_date, trunc):
          
          date_headers = list(date_headers)
  
          # Earliest date should be no earlier than from_date.
          if date_headers and date_headers[0] < from_date:
              date_headers[0] = from_date
  
          # When organizing by week or month, create a list of the range for
          # each date header.
          if date_headers and trunc != 'day':
              count = len(date_headers)
              range_headers = [0] * count
              for i in range(count - 1):
                  range_headers[i] = (
                      date_headers[i], date_headers[i + 1] - relativedelta(days=1))
              range_headers[count - 1] = (date_headers[count - 1], to_date)
          else:
              range_headers = date_headers
          return date_headers, range_headers
docs: Adjust date headers & get range headers.