def METHOD_NAME(filename):
    base_name, _ext = os.path.splitext(filename)
    parts = base_name.split("-")
    if len(parts) < 6:
        raise ValueError(
            "Inavlid filename - it must be in the form 'YYYY-MM-DD-HH-MM-SS[-i].xml'"
        )
    parts_dict = dict(zip(["year", "month", "day", "hour", "min", "sec"], parts))
    # pylint: disable=consider-using-f-string
    return datetime.strptime(
        "%(year)s-%(month)s-%(day)s-%(hour)s-%(min)s-%(sec)s" % parts_dict,
        DATE_FORMAT,
    )