from datetime import datetime


def convert_date_windows(qif_date):
    """
    Convert a date with Quicken strange format to a YYYY-MM-DD.

    Notes:
    qif date format on windows for dates after 1999

    Example of the format we're dealing with: 2/ 1' 3
    here, 2 is the month, 1 is the day and 3 is the year
    """

    # first split we'll get month and rest
    month, rest = qif_date.split('/')
    day, year = rest.split("'")

    # remove whitespace
    month = month.strip()
    day = day.strip()
    year = year.strip()

    # pad with zeros
    if len(month) < 2:
        month = f'0{month}'
    if len(day) < 2:
        day = f'0{day}'

    if len(year) < 2:
        year = f'200{year}'
    elif len(year) < 3:
        year = f'20{year}'

    return datetime(int(year), int(month), int(day)).strftime("%Y-%m-%d")