def METHOD_NAME(dob):
    today = datetime.date.today()
    if type(dob) == datetime.date:
        DOB = dob
    else:
        try:
            DOB = parser.parse(dob).date()
        except (TypeError, ValueError):
            return None
    if DOB < today:
        try:  # when dob is 2/29 and the current year is not a leap year
            birthday = DOB.replace(year=today.year)
        except ValueError:
            birthday = DOB.replace(year=today.year, day=DOB.day - 1)
        if birthday > today:
            return today.year - DOB.year - 1
        else:
            return today.year - DOB.year
    else:
        return None