from datetime import datetime


def is_current(record,year):
    """
    Utility function to check whether a record is valid for the current year.
    Since records contain different information about dates, as appropriate,
    there are multiple conditions that must be tested.

    a) if a record contains only a YEAR, it's value must match the given `year`
    b) if a record contains a STARTYEAR (and therefore an ENDYEAR), the given `year`
       must lie in the interval [STARTYEAR, ENDYEAR]
    c) if a record contains a STARTDATE (and therefore an ENDDATE), the given `year`
       must lie in the interval [STARTDATE, ENDDATE]
    d) if a record contains a DATE, the DATE must be in the given `year`

    inputs
    ------
    year : (int) year of interest to be matched

    output
    ------
    Boolean per the above conditions
    """

    if 'YEAR' in record.keys():
        return record['YEAR'] == year
    elif 'STARTYEAR' in record.keys():
        return (record['STARTYEAR'] <= year and record['ENDYEAR'] >= year)
    elif 'STARTDATE' in record.keys():
        start_date_obj = datetime.strptime(record['STARTDATE'],"%m/%d/%y")
        end_date_obj = datetime.strptime(record['ENDDATE'],"%m/%d/%y")
        return (start_date_obj.year <= year and end_date_obj.year >= year)
    elif 'DATE' in record.keys():
        date_obj = datetime.strptime(record['DATE'],"%m/%d/%y")
        return date_obj.year == year
    else:
        return False