def has_valid_birthday(self, value):
        """
        This function would grab the birthdate from the ID card number and test
        whether it is a valid date.
        """
        from datetime import datetime
        if len(value) == 15:
            # 1st generation ID card
            time_string = value[6:12]
            format_string = "%y%m%d"
        else:
            # 2nd generation ID card
            time_string = value[6:14]
            format_string = "%Y%m%d"
        try:
            datetime.strptime(time_string, format_string)
            return True
        except __HOLE__:
            # invalid date
            return False
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.4/django/contrib/localflavor/cn/forms.py/CNIDCardField.has_valid_birthday