stdnum.pl.pesel

PESEL (Polish national identification number).

The Powszechny Elektroniczny System Ewidencji Ludności (PESEL, Universal Electronic System for Registration of the Population) is a 11-digit Polish national identification number. The number consists of the date of birth, a serial number, the person’s gender and a check digit.

>>> validate('44051401359')
'44051401359'
>>> validate('44051401358')  # incorrect check digit
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('02381307589')  # invalid birth date
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> get_birth_date('02122401358')
datetime.date(1902, 12, 24)
>>> get_gender('02122401358')
'M'
>>> get_birth_date('02211307589')
datetime.date(2002, 1, 13)
>>> get_gender('02211307589')
'F'
stdnum.pl.pesel.calc_check_digit(number)

Calculate the check digit for organisations. The number passed should not have the check digit included.

stdnum.pl.pesel.compact(number)

Convert the number to the minimal representation. This strips the number of any valid separators and removes surrounding whitespace.

stdnum.pl.pesel.get_birth_date(number)

Split the date parts from the number and return the birth date.

stdnum.pl.pesel.get_gender(number)

Get the person’s birth gender (‘M’ or ‘F’).

stdnum.pl.pesel.is_valid(number)

Check if the number is a valid national identification number.

stdnum.pl.pesel.validate(number)

Check if the number is a valid national identification number. This checks the length, formatting and check digit.