def time_format(dt):
    """
    timeformat must match Elasticsearch `strict_date_time` format:
    https://www.elastic.co/guide/en/elasticsearch/reference/7.16/mapping-date-format.html
    """
    s = dt.strftime("%Y-%m-%dT%H:%M:%S.%f")
    return f"{s[:-3]}Z"