Return a dict with the bounds for a date_histogram agg.

        :param start: date from for the date_histogram agg, should be a datetime.datetime object
        :param end: date to for the date_histogram agg, should be a datetime.datetime object
        :return: a dict with the DSL bounds for a date_histogram aggregation

def __get_bounds(cls, start=None, end=None):
        """
        Return a dict with the bounds for a date_histogram agg.

        :param start: date from for the date_histogram agg, should be a datetime.datetime object
        :param end: date to for the date_histogram agg, should be a datetime.datetime object
        :return: a dict with the DSL bounds for a date_histogram aggregation
        """
        bounds = {}
        if start or end:
            # Extend bounds so we have data until start and end
            start_ts = None
            end_ts = None
            if start:
                # elasticsearch is unable to convert date with microseconds into long
                # format for processing, hence we convert microseconds to zero
                start = start.replace(microsecond=0)
                start_ts = start.replace(tzinfo=timezone.utc).timestamp()
                start_ts_ms = start_ts * 1000  # ES uses ms
            if end:
                end = end.replace(microsecond=0)
                end_ts = end.replace(tzinfo=timezone.utc).timestamp()
                end_ts_ms = end_ts * 1000  # ES uses ms

            bounds_data = {}
            if start:
                bounds_data["min"] = start_ts_ms
            if end:
                bounds_data["max"] = end_ts_ms

            bounds["extended_bounds"] = bounds_data
        return bounds