def dates(self, field_name, kind, order='ASC'):
        """
        Returns a list of datetime objects representing all available dates for
        the given field_name, scoped to 'kind'.
        """

        assert kind in ("month", "year", "day", "week", "hour", "minute"), \
                "'kind' must be one of 'year', 'month', 'day', 'week', 'hour' and 'minute'."
        assert order in ('ASC', 'DESC'), \
                "'order' must be either 'ASC' or 'DESC'."

        search= self._build_search()
        search.facet.reset()
        search.facet.add_date_facet(name=field_name.replace("__", "."),
                 field=field_name, interval=kind)
        search.agg.reset()
        search.agg.add_date_agg(name=field_name.replace("__", "."),
                 field=field_name, interval=kind)
        search.size=0
        resulset = get_es_connection(self.es_url, self.es_kwargs).search(search, indices=self.index, doc_types=self.type)
        resulset.fix_aggs()
        entries = []
        for val in resulset.aggs.get(field_name.replace("__", ".")).get("entries", []):
            if val in "time":
                entries.append(val["time"])
        if order=="ASC":
            return sorted(entries)

        return sorted(entries, reverse=True)
dataset/ETHPy150Open aparo/pyes/pyes/queryset.py/QuerySet.dates/swapped operands of `in`