def get_year_filter(year):
    """Creates a filter for a year"""

    def year_filter(occurrence):
        """Filter for years

        Using the year captured the closure, returns false if the occurrence
        is before the year, true when is in the year and stops when is past
        """
        if year == "*":
            return True
        else:
            valid_year = int(year)
            if occurrence.year < valid_year:
                return False
            elif occurrence.year > valid_year:
                raise StopIteration("Valid time already past")
            else:
                return True

    return year_filter