Ë
    Ã?Æib  ã                  ó^   — 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„Z	dd„Z
dd	„Zdd
„Zy)u-  NI (NÃºmero de identidad, Cuban identity card numbers).

NÃºmero de carnet de identidad is the Cuban national identifier that is
assigned to residents. The number consists of 11 digits and include the date
of birth of the person and gender.

More information:

* https://www.postdata.club/issues/201609/es-usted-unico-en-cuba.html

>>> validate('91021027775')
'91021027775'
>>> validate('9102102777A')
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> get_birth_date('91021027775')
datetime.date(1991, 2, 10)
>>> get_gender('91021027775')
'F'
>>> get_birth_date('72062506561')
datetime.date(1972, 6, 25)
>>> get_gender('72062506561')
'M'
>>> get_birth_date('85020291531')
datetime.date(1885, 2, 2)
>>> get_birth_date('02023061531')
Traceback (most recent call last):
    ...
InvalidComponent: ...
é    )ÚannotationsN)Ú*)ÚcleanÚisdigitsc                ó6   — t        | d«      j                  «       S )zmConvert the number to the minimal representation. This strips
    surrounding whitespace and separation dash.ú )r   Ústrip©Únumbers    úS/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/cu/ni.pyÚcompactr   =   s   € ô �˜Ó×#Ñ#Ó%Ð%ó    c                ó  — t        | «      } t        | dd «      }t        | dd «      }t        | dd «      }| d   dk(  r|dz  }nd| d   cxk  rdk  r	n n|d	z  }n|d
z  }	 t        j                  |||«      S # t        $ r t        «       ‚w xY w)zBSplit the date parts from the number and return the date of birth.r   é   é   é   Ú9i  Ú0Ú5il  iÐ  )r   ÚintÚdatetimeÚdateÚ
ValueErrorÚInvalidComponent)r   ÚyearÚmonthÚdays       r   Úget_birth_dater   C   s£   € ä�V‹_€FÜˆv�a˜ˆ{Ó€DÜ��q˜�Ó€EÜ
ˆf�Q�qˆkÓ
€CØˆa�y�CÒØ�‰‰Ø	��q‘	Ô	 ˜SÕ	 Ø�‰‰à�‰ˆð!Ü�}‰}˜T 5¨#Ó.Ð.øÜò !ÜÓ Ð ð!ús   Á!A8 Á8Bc                ó>   — t        | «      } t        | d   «      dz  ryy)z*Get the gender (M/F) from the person's NI.é	   r   ÚFÚM)r   r   r
   s    r   Ú
get_genderr#   U   s!   € ä�V‹_€FÜ
ˆ6�!‰9ƒ~˜ÒØàr   c                óŒ   — t        | «      } t        | «      dk7  r
t        «       ‚t        | «      s
t	        «       ‚t        | «       | S )zZCheck if the number is a valid NI. This checks the length, formatting
    and check digit.é   )r   ÚlenÚInvalidLengthr   ÚInvalidFormatr   r
   s    r   Úvalidater)   ^   s>   € ô �V‹_€FÜ
ˆ6ƒ{�bÒÜ‹oÐÜ�FÔÜ‹oÐÜ�6ÔØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z"Check if the number is a valid NI.F)Úboolr)   ÚValidationErrorr
   s    r   Úis_validr-   j   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡")r   ÚstrÚreturnr.   )r   r.   r/   zdatetime.date)r   r.   r/   r+   )Ú__doc__Ú
__future__r   r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r   r#   r)   r-   © r   r   ú<module>r5      s2   ðñ*õ@ #ã ä ß 'ó&ó!ó$ó	ôr   