def year_extract(date):
    """

    Extract year from a date.
    Assumes `date` to contain a year of the form: YYYY.

    :param date: a string containing a year
    :type date: ``str``
    :return: the first year found in string
    :rtype: ``str`` or ``None``
    """
    year = ''
    for c in str(date):
        if len(year) == 4:
            break
        if c.isdigit():
            year += c
        elif not c.isdigit() and len(year) < 4:
            year = ''
    return year if len(year) == 4 else None
