Ë
    Ã?Æi¯  ã                  ó`   — d Z ddlmZ ddlZddl­ ddlmZmZ dd„Zddd„Z	dd„Z
dd	„Zdd
„Zy)a‘  NIK (Nomor Induk Kependudukan, Indonesian identity number).


The Nomor Induk Kependudukan (NIK, Population Identification Number,
sometimes known as Nomor Kartu Tanda Penduduk or Nomor KTP) is issued to
Indonesian citizens.

The number consists of 16 digits in the format PPRRSSDDMMYYXXXX where PPRRSS
(province, city/district, sub-district) indicates the place of residence when
the number was issued. It is followed by a DDMMYY date of birth (for female
40 is added to the day). The last 4 digits are used to make the number
unique.

More information:

* https://id.wikipedia.org/wiki/Nomor_Induk_Kependudukan

>>> validate('3171011708450001')
'3171011708450001'
>>> validate('31710117084500')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> validate('9971011708450001')  # invalid province
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> get_birth_date('3171015708450001')
datetime.date(1945, 8, 17)
>>> get_birth_date('3171012902001234')  # 1900-02-29 doesn't exist
datetime.date(2000, 2, 29)
>>> get_birth_date('3171013002001234')  # 1900-20-30 doesn't exist
Traceback (most recent call last):
    ...
InvalidComponent: ...
é    )ÚannotationsN)Ú*)ÚcleanÚisdigitsc                ó6   — t        | d«      j                  «       S )z’Convert the number to the minimal representation.

    This strips the number of any valid separators and removes
    surrounding whitespace.
    z -.)r   Ústrip©Únumbers    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/id/nik.pyÚcompactr   B   s   € ô �˜Ó×%Ñ%Ó'Ð'ó    c                ó*  — t        | «      } t        | dd «      dz  }t        | dd «      }t        | dd «      }	 t        j                  |dz   ||«      S # t        $ r Y nw xY w	 t        j                  |dz   ||«      S # t        $ r t        «       ‚w xY w)z—Get the birth date from the person's NIK.

    Note that the number only encodes the last two digits of the year so
    this may be a century off.
    é   é   é(   é
   é   il  iÐ  )r   ÚintÚdatetimeÚdateÚ
ValueErrorÚInvalidComponent)r
   ÚminyearÚdayÚmonthÚyears        r   Úget_birth_dater   K   s¤   € ô �V‹_€FÜ
ˆf�Q�qˆkÓ
˜RÑ
€CÜ��q˜�Ó€EÜˆv�b˜ˆ}Ó€DðÜ�}‰}˜T D™[¨%°Ó5Ð5øÜò Ùðúð!Ü�}‰}˜T D™[¨%°Ó5Ð5øÜò !ÜÓ Ð ð!ús   ºA Á	A ÁA Á$A> Á>Bc                ó|   — ddl m} |j                  d«      j                  | dd «      d   d   }|s
t	        «       ‚|S )zBUse the number to look up the place of registration of the person.r   )Únumdbzid/locNé   é   )Ústdnumr   ÚgetÚinfor   )r
   r   Úresultss      r   Ú_check_registration_placer&   _   s?   € åØ�i‰i˜Ó!×&Ñ& v¨b¨q zÓ2°1Ñ5°aÑ8€GÙÜÓ Ð Ø€Nr   c                ó¢   — t        | «      } t        | «      s
t        «       ‚t        | «      dk7  r
t	        «       ‚t        | «       t        | «       | S )ú.Check if the number is a valid Indonesian NIK.é   )r   r   ÚInvalidFormatÚlenÚInvalidLengthr   r&   r	   s    r   Úvalidater-   h   sD   € ä�V‹_€FÜ�FÔÜ‹oÐÜ
ˆ6ƒ{�bÒÜ‹oÐÜ�6ÔÜ˜fÔ%Ø€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)r(   F)Úboolr-   ÚValidationErrorr	   s    r   Úis_validr1   t   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡")r
   ÚstrÚreturnr2   )i€  )r
   r2   r   r   r3   zdatetime.date)r
   r2   r3   zdict[str, str])r
   r2   r3   r/   )Ú__doc__Ú
__future__r   r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r   r&   r-   r1   © r   r   ú<module>r9      s2   ðñ*#õJ #ã ä ß 'ó(ô!ó(ó	ôr   