from datetime import datetime


def parse_date(date_string):
    """
    Small function to parse a string into a datetime object since it can come in multiple formats from the external API.
    """

    if not date_string:
        return None

    for date_format in ["%Y-%m-%d", "%Y-%m", "%Y"]:
        try:
            return datetime.strptime(date_string, date_format)
        except ValueError:
            pass

    print(f'Date format not understood: "{date_string}"')