Ë
    Ã?ÆiR  ã                  óz   — d Z ddlmZ ddlZddlmZ ddl­ ddlmZm	Z	 dd„Z
dd„Zdd	„Zdd
„Zdd„Zdd„Zdd„Zy)aG  ID number (South African Identity Document number).

The South African ID number is issued to individuals within South Africa. The
number consists of 13 digits and contains information about a person's date
of birth, gender and whether the person is a citizen or permanent resident.

More information:

* https://en.wikipedia.org/wiki/South_African_identity_card
* https://www.dha.gov.za/index.php/identity-documents2

>>> validate('7503305044089')
'7503305044089'
>>> validate('8503305044089')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('9125568')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> get_gender('7503305044089')
'M'
>>> get_birth_date('7503305044089')
datetime.date(1975, 3, 30)
>>> get_citizenship('7503305044089')
'citizen'
>>> format('750330 5044089')
'750330 5044 08 9'
é    )ÚannotationsN)Úluhn)Ú*)ÚcleanÚisdigitsc                ó   — t        | d«      S )z’Convert the number to the minimal representation.

    This strips the number of any valid separators and removes surrounding
    whitespace.
    ú )r   ©Únumbers    úU/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/za/idnr.pyÚcompactr   =   s   € ô �˜ÓÐó    c                óT  — t        | «      } t        j                  j                  «       }t	        | dd «      d|j
                  dz  z  z   }t	        | dd «      }t	        | dd «      }||j
                  kD  r|dz  }	 t        j                  |||«      S # t        $ r t        «       ‚w xY w)z¢Split the date parts from the number and return the date of birth.

    Since the number only uses two digits for the year, the century may be
    incorrect.
    r   é   éd   é   é   )r   ÚdatetimeÚdateÚtodayÚintÚyearÚ
ValueErrorÚInvalidComponent)r   r   r   ÚmonthÚdays        r   Úget_birth_dater   F   s§   € ô �V‹_€FÜ�M‰M×ÑÓ!€EÜˆv�a˜ˆ{Ó˜s e§j¡j°CÑ&7Ñ8Ñ9€DÜ��q˜�Ó€EÜ
ˆf�Q�qˆkÓ
€CØˆe�j‰jÒØ�‰ˆð!Ü�}‰}˜T 5¨#Ó.Ð.øÜò !ÜÓ Ð ð!ús   Á<B ÂB'c                ó*   — t        | «      } | d   dv ryy)z1Get the gender (M/F) from the person's ID number.r   Ú01234ÚFÚM)r   r
   s    r   Ú
get_genderr"   Y   s   € ä�V‹_€FØˆa�y�GÑØàr   c                óP   — t        | «      } | d   dk(  ry| d   dk(  ryt        «       ‚)zAGet the citizenship status (citizen/resident) from the ID number.é
   Ú0ÚcitizenÚ1Úresident)r   r   r
   s    r   Úget_citizenshipr)   b   s2   € ä�V‹_€FØˆb�z�SÒØØ	�‰�sÒ	ØäÓ Ð r   c                óÈ   — t        | «      } t        | «      s
t        «       ‚t        | «      dk7  r
t	        «       ‚t        | «       t        | «       t        j                  | «      S )zuCheck if the number is a valid South African ID number.

    This checks the length, formatting and check digit.
    é   )	r   r   ÚInvalidFormatÚlenÚInvalidLengthr   r)   r   Úvalidater
   s    r   r/   r/   m   sP   € ô
 �V‹_€FÜ�FÔÜ‹oÐÜ
ˆ6ƒ{�bÒÜ‹oÐÜ�6ÔÜ�FÔÜ�=‰=˜Ó Ð r   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z7Check if the number is a valid South African ID number.F)Úboolr/   ÚValidationErrorr
   s    r   Úis_validr3   |   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                óZ   — t        | «      } dj                  | dd | dd | dd | dd f«      S )z8Reformat the number to the standard presentation format.r	   Nr   r$   é   )r   Újoinr
   s    r   Úformatr7   „   s;   € ä�V‹_€FØ�8‰8�V˜B˜Q�Z ¨¨" ¨v°b¸¨}¸fÀRÀS¸kÐJÓKÐKr   )r   ÚstrÚreturnr8   )r   r8   r9   zdatetime.date)r   r8   r9   r1   )Ú__doc__Ú
__future__r   r   Ústdnumr   Ústdnum.exceptionsÚstdnum.utilr   r   r   r   r"   r)   r/   r3   r7   © r   r   ú<module>r@      s?   ðñ*õ> #ã å Ü ß 'óó!ó&ó!ó!óôLr   