def clean(self, value):
        super(EEPersonalIdentificationCode, self).clean(value)
        if value in EMPTY_VALUES:
            return ''

        match = re.match(idcode, value)
        if not match:
            raise ValidationError(self.error_messages['invalid_format'])

        century, year, month, day, check = map(int, match.groups())

        if check != self.ee_checksum(value[:10]):
            raise ValidationError(self.error_messages['invalid'])

        # Century digit also encodes gender:
        # 1 - male born in 18xx
        # 2 - female born in 18xx
        # 3 - male born in 19xx
        # ...
        year += 1800 + 100 * ((century - 1) // 2)
        try:
            date(year, month, day)
        except __HOLE__:
            raise ValidationError(self.error_messages['invalid'])

        return value
dataset/ETHPy150Open django/django-localflavor/localflavor/ee/forms.py/EEPersonalIdentificationCode.clean