'Reformats a string containing either seconds from epoch or an iso8601 formated
date string into a new date string usable within a filter query.
Seconds from epoch can be a floating point value as well (i.e containing ms).'

def parse_date(self, date_string):

    try:
        epoch = float(date_string)
        datetime_obj = datetime.datetime.fromtimestamp(epoch)
        return datetime_obj.isoformat(sep='    ')
    except ValueError:
        pass
    match = self.date_string_re.match(date_string)
    if match:
        date_string = '    '.join([group for group in match.groups() if group])
        return date_string
    raise ValueError('datetime    strings    must    be    in    the    ISO    8601    format    and    in    the    UTC')
