Ë
    Ã?Æi•  ã                  ón   — 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dd„Zdd„Zy)aS  RIC No. (Chinese Resident Identity Card Number).

The RIC No. is the unique identifier for issued to China (PRC) residents.

The number consist of 18 digits in four sections. The first 6 digits refers to
the resident's location, followed by 8 digits representing the resident's birth
day in the form YYYY-MM-DD. The next 3 digits is the order code which is the
code used to disambiguate people with the same date of birth and address code.
Men are assigned to odd numbers, women assigned to even numbers. The final
digit is the checksum.

>>> validate('360426199101010071')
'360426199101010071'
é    )ÚannotationsN)Ú*)ÚcleanÚisdigitsc                óP   — t        | «      j                  «       j                  «       S )zˆConvert the number to the minimal representation. This strips the
    number of any valid separators and removes surrounding whitespace.)r   ÚupperÚstrip©Únumbers    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/cn/ric.pyÚcompactr   ,   s    € ô �‹=×ÑÓ ×&Ñ&Ó(Ð(ó    c                óÊ   — t        | «      } t        | dd «      }t        | dd «      }t        | dd «      }	 t        j                  |||«      S # t        $ r t        «       ‚w xY w)zºSplit the date parts from the number and return the birth date.
    Note that in some cases it may return the registration date instead of
    the birth date and it may be a century off.é   é
   é   é   )r   ÚintÚdatetimeÚdateÚ
ValueErrorÚInvalidComponent)r   ÚyearÚmonthÚdays       r   Úget_birth_dater   2   sm   € ô �V‹_€FÜˆv�a˜ˆ|Ó€DÜ��r˜"�Ó€EÜ
ˆf�R˜ˆmÓ
€Cð!Ü�}‰}˜T 5¨#Ó.Ð.øÜò !ÜÓ Ð ð!ús   ·A ÁA"c           	     ó8  — ddl m} t        | «      } |j                  d«      j	                  | dd «      }|D ����ci c]   \  }}|j                  «       D ]  \  }}||“Œ
 Œ" }}}}}|s
t        «       ‚t        | «      j                  }|d   j                  d«      D ]l  }	|	j                  d«      s|c S |	d	d j                  d
«      \  }
}	|
j                  d«      \  }}|r|t        |«      k  rŒT|r|t        |«      kD  rŒe|	|d<   |c S  t        «       ‚c c}}}}w )z;Use the number to look up the place of birth of the person.r   )Únumdbzcn/locNr   Úcountyú,ú[é   ú]ú-)Ústdnumr   r   ÚgetÚinfoÚitemsr   r   r   ÚsplitÚ
startswithr   )r   r   ÚresultsÚpartÚpropsÚkÚvr'   r   r   ÚstartendÚstartÚends                r   Úget_birth_placer3   @   s  € åÜ�V‹_€FØ�i‰i˜Ó!×&Ñ& v¨b¨q zÓ2€GØ$+×FÑF‘[�T˜5¸¿¹»ÒF±°°1ˆAˆq‰DÐFˆAÐF€DÓFÙÜÓ Ð Ü˜&Ó!×&Ñ&€Dà�x‘.×&Ñ& sÓ+ò 
ˆØ× Ñ  Ô%ØŠKØ! ! "˜:×+Ñ+¨CÓ0Ñˆ�&Ø—^‘^ CÓ(‰
ˆˆsÙ�TœC ›JÒ&ØÙ�4œ#˜c›(’?ØØˆˆX‰ØŠð
ô Ó
Ðùõ# Gs   ¼%D
c                óV   — ddt        | dd d«      z  z
  dz  }|dk(  rdS t        |«      S )	zVCalculate the check digit. The number passed should have the check
    digit included.r"   é   Néÿÿÿÿé   é   r   ÚX)r   Ústr)r   Úchecksums     r   Úcalc_check_digitr<   Y   s:   € ð �Aœ˜F 3 B˜K¨Ó,Ñ,Ñ,°Ñ2€HØ˜b’.ˆ3Ð3¤c¨(£mÐ3r   c                óÞ   — t        | «      } t        | «      dk7  r
t        «       ‚t        | dd «      s
t	        «       ‚| d   t        | «      k7  r
t        «       ‚t        | «       t        | «       | S )zkCheck if the number is a valid RIC number. This checks the length,
    formatting and birth date and place.é   Nr6   )	r   ÚlenÚInvalidLengthr   ÚInvalidFormatr<   ÚInvalidChecksumr   r3   r
   s    r   ÚvalidaterC   `   sg   € ô �V‹_€FÜ
ˆ6ƒ{�bÒÜ‹oÐÜ�F˜3˜B�KÔ Ü‹oÐØˆb�zÔ% fÓ-Ò-ÜÓÐÜ�6ÔÜ�FÔØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z*Check if the number is a valid RIC number.F)ÚboolrC   ÚValidationErrorr
   s    r   Úis_validrG   o   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                ó   — t        | «      S )z8Reformat the number to the standard presentation format.)r   r
   s    r   ÚformatrI   w   s   € ä�6‹?Ðr   )r   r:   Úreturnr:   )r   r:   rJ   zdatetime.date)r   r:   rJ   zdict[str, str])r   r:   rJ   rE   )Ú__doc__Ú
__future__r   r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r   r3   r<   rC   rG   rI   © r   r   ú<module>rP      s;   ðñ*õ #ã ä ß 'ó)ó!óó24óóôr   