# stdnum.se.personnummer

Personnummer (Swedish personal identity number).

The Swedish Personnummer is assigned at birth to all Swedish nationals and to immigrants for tax and identification purposes. The number consists of 10 or 12 digits and starts with the birth date, followed by a serial and a check digit.

More information:

- https://en.wikipedia.org/wiki/Personal_identity_number_(Sweden)

    >>> validate('880320-0016')
    '880320-0016'
    >>> validate('8803200016')
    '880320-0016'
    >>> validate('880320-0018')
    Traceback (most recent call last):
        ...
    InvalidChecksum: ...
    >>> get_gender('890102-3286')
    'F'
    >>> get_birth_date('811228-9841')
    datetime.date(1981, 12, 28)
    >>> format('8803200016')
    '880320-0016'

`stdnum.se.personnummer.``compact`(number)

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

`stdnum.se.personnummer.``format`(number)

  Reformat the number to the standard presentation format.

`stdnum.se.personnummer.``get_birth_date`(number)

  Guess the birth date from the number.

  Note that it may be 100 years off because the number has only the last two digits of the year.

`stdnum.se.personnummer.``get_gender`(number)

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

`stdnum.se.personnummer.``is_valid`(number)

  Check if the number is a valid identity number.

`stdnum.se.personnummer.``validate`(number)

  Check if the number is a valid identity number.