# stdnum.fi.hetu

HETU (Henkilötunnus, Finnish personal identity code).

Module for handling Finnish personal identity codes (HETU, Henkilötunnus). See https://www.vaestorekisterikeskus.fi/default.aspx?id=45 for checksum calculation details and https://tarkistusmerkit.teppovuori.fi/tarkmerk.htm#hetu1 for historical details.

    >>> validate('131052-308T')
    '131052-308T'
    >>> validate('131052-308U')
    Traceback (most recent call last):
        ...
    InvalidChecksum: ...
    >>> validate('310252-308Y')
    Traceback (most recent call last):
        ...
    InvalidComponent: ...
    >>> compact('131052a308t')
    '131052A308T'

stdnum.fi.hetu.compact(number)

  Convert the HETU to the minimal representation. This strips surrounding whitespace and converts it to upper case.

stdnum.fi.hetu.format(number)

  Convert the HETU to the minimal representation. This strips surrounding whitespace and converts it to upper case.

stdnum.fi.hetu.is_valid(number, allow_temporary=False)

  Check if the number is a valid HETU.

stdnum.fi.hetu.validate(number, allow_temporary=False)

  Check if the number is a valid HETU. It checks the format, whether a valid date is given and whether the check digit is correct. Allows temporary identifier range for individuals (900-999) if allow_temporary is True.