'This function convert date_histogram facets to datetime'

def fix_facets(self):

    facets = self.facets
    for key in list(facets.keys()):
        _type = facets[key].get('_type', 'unknown')
        if (_type == 'date_histogram'):
            for entry in facets[key].get('entries', []):
                for (k, v) in list(entry.items()):
                    if (k in ['count', 'max', 'min', 'total_count', 'mean', 'total']):
                        continue
                    if (not isinstance(entry[k], datetime)):
                        entry[k] = datetime.utcfromtimestamp((v / 1000.0))
