def replaceDateArgs(query, query_start_time, query_end_time):
    """
    Replace the date arguments in the range filter of the query.
    """

    if not 'filter' in query:
        query['filter']['range']['@timestamp']['gte'] = query_start_time.isoformat()
        query['filter']['range']['@timestamp']['lt'] = query_end_time.isoformat()
    else:
        query['post_filter']['range']['@timestamp']['gte'] = query_start_time.isoformat()
        query['post_filter']['range']['@timestamp']['lt'] = query_end_time.isoformat()

    return query