
    <e,                         d Z ddlZddlZddlZddlmZ ddlZddlZd Zd Z	 G d dej
                  Z G d d	ej
                  Zed
k    r ej                     dS dS )z
Unittest for time.strftime
    N)supportc                 N    | d         dk    r| d d         dz   | dd          z   } | S )N    0	    )ss    )/usr/lib/python3.11/test/test_strftime.py
fixasctimer      s2    ts{{bqbECK!ABB%H    c                    t          j        |           }|                    t          j        |          |          }|                    dd          }|                    dd          }|                    dd          }|S )z
    Escape text to deal with possible locale values that have regex
    syntax while allowing regex syntax used for comparison.
    z\%%z\::z\??)reescapereplace)textampmnew_texts      r   	escapestrr      sr    
 yH	$66Hs++Hs++Hs++HOr   c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )StrftimeTestc                 4   t          j        |          | _        t          j        |          }|d         dk     rd| _        nd| _        t          j        t          j        |d         ddddddddf	                    | _        	 |d         rt           j        d         | _        nt           j        d         | _        n# t          $ r
 d| _        Y nw xY w|d         dk    r|d         dz
  | _
        n!|d         dk    r|d         | _
        nd| _
        || _        d S )	N      z(AM|am)z(PM|pm)r      r    )timegmtimegmt	localtimer   mktimejan1tznametzAttributeErrorclock12now)selfr*   s     r   _update_variableszStrftimeTest._update_variables"   s   ;s##nS!!q6B;;)		!diN4;A1aAq!Q/O#P#PQQ		1v +Qtww KN$' 	 	 	DGGG	 q6B;;s1v{VaZZAdls   7B< <CCc                     	 dd l }|j        j                            |j        j        j                   d S # t
          $ r: ddlm}m}  ||          } ||d           | 	                    |||           Y d S w xY w)Nr   )	setlocaleLC_TIMEC)
javautilLocale
setDefaultUSImportErrorlocaler.   r/   
addCleanup)r+   r1   r.   r/   saved_locales        r   setUpzStrftimeTest.setUp8   s    	>KKKI''	(8(;<<<<< 	> 	> 	>11111111$9W--LIgs###OOIw======		>s   26 A A:9A:c                 .   t          j                     }|                     |           |                     |           |                     |           t          j        rAt          dt          j        dt          j	        
                                d                    t          dd          D ]d}t          d          D ]R}|||dz  z   dz  d	z  z   }|                     |           |                     |           |                     |           Sed S )
NzStrftime test, platform: z, Python version: r         d      i  )r    r,   	strftest1	strftest2r   verboseprintsysplatformversionsplitrange)r+   r*   jiargs        r   test_strftimezStrftimeTest.test_strftimeB   s   ikks###ss? 	:E<<<!2!2!4!4Q!7!79 : : : r1 	$ 	$A2YY $ $QquWbL--&&s+++s###s####	$	$ 	$r   c                    t           j        r"t          dt          j        |                     | j        }dt          j        |d                  dfdt          j        |d                  dfdt          j	        |d                  d	fd
t          j
        |d                  dfdd|d         z  dfdd|d         z  dfdd| j        z  dfdd|d         z  dfdd|d         z  dfdd|d         z  dfd| j        dfd d|d!         z  d"fd#d|d         | j        d         z   dz  z  d$fd%d&d|d         z   dz  z  d'fd(d|d         | j        d         dz
  dz  z   dz  z  d)fd*d+|d         |d         |d!         fz  d,fd-d|d.         d/z  z  d0fd1d|d.         z  d2fd3f}|D ]}	 t          j        |d.         |          }n8# t          $ r+}|                     d4|d.         d5|           Y d }~nd }~ww xY wt#          j        t'          |d         | j                  |          r|r|d.         d6k    r)|                     d7|d.         d8|d         d9           |                     d:|d.         d;|d         d<|d         d=|           d S )>Nzstrftime test forz%a   zabbreviated weekday namez%Azfull weekday namez%br   abbreviated month namez%Bzfull month namez%dz%02d   zday of month as number (00-31)z%Hr   zhour (00-23)z%Izhour (01-12)z%j%03d   zjulian day (001-366)z%mzmonth as number (01-12)z%M   zminute, (00-59)z%pzAM or PM as appropriatez%Sr=   zseconds of current time (00-60)z%Uz!week number of the year (Sun 1st)z%wz0?%dzweekday as a number (Sun 1st)z%Wz!week number of the year (Mon 1st)z%X%02d:%02d:%02d%H:%M:%S%yr   r?   zyear without centuryz%Yzyear with century)z%%r   zsingle percent signz
strftime 'z' format gave error: r   z$strftime does not support standard '
' format ()zConflict for z (z): expected 
, but got )r   rC   rD   r    ctimer*   calendarday_abbrday_name
month_abbr
month_namer)   r   r%   strftime
ValueErrorfailr   matchr   )r+   r*   expectationseresulterrors         r   rA   zStrftimeTest.strftest1S   s-   ? 	8%tz#777h 8$SV,.HI8$SV,.AB8&s1v.0HI8&s1v.0AB6CF?$DE6CF?N36DL(.96CF?$:;6CF?$=>6CF?$5649786CF?$EF6c!fty|3a78026aAh!^,.MN6c!f	!q(8!';;a?@/1 #s1vs1vs1v&>>
K6SVCZ(*@A4#a&="56.1
6  	8 	8AQqtS11 Q Q Q			1Q444OPPPPPPPPQx	!A$	22F;;  8VAY#--			qTTT1Q444) * * * * 			qTTT1Q4441vv7 8 8 8 8	8 	8s   F33
G(=!G##G(c                 .   t          t          |                    d d         }| j        }dt          t	          j        |                    dfdd|d         |d         |d         d	z  fz  d
fdd| j        z  dfdd|d         |d         |d         d	z  fz  dfdd|d         z  dfdt          j        |d                  dfdd|d         z  dfddd| j	        |d         |d         | j
        fz  dfdd|d         |d         fz  d fd|d!fd"d#d$|d         |d         |d         fz  d%fd&d'|d         d	z  z  d(ff}|D ]Z}	 t	          j        |d         |          }nV# t          $ rI}d)|d         d*|d         d+t          |          }t          j        rt          |           Y d }~nd }~ww xY wt!          j        t%          |d         | j
                  |          r/t          j        r"t          d,|d         d*|d         d-           |r|d         d.k    r0t          j        r"t          d/|d         d*|d         d-           t          j        r=t          d0|d         d*|d         d1           t          d2|d         d3|           \d S )4Nz%cznear-asctime() formatz%xz%02d/%02d/%02dr   rQ   r   r?   z%m/%d/%y %H:%M:%Sz%Zz%sztime zone namez%Dzmm/dd/yyz%ez%2dz,day of month as number, blank padded ( 0-31)z%hrP   z%kr   zhour, blank padded ( 0-23))z%n
znewline characterz%rz%02d:%02d:%02d %srT   r=   z%I:%M:%S %pz%Rz	%02d:%02dz%H:%Mzseconds since the Epoch in UCT)z%t	ztab characterz%TrU   rV   z%3yrR   z.year without century rendered using fieldwidthzError for nonstandard 'rX   z): zSupports nonstandard 'rY   r   zDoes not appear to support 'zConflict for nonstandard 'z):z  Expected rZ   )strintr*   r   r    asctimer'   r\   r_   r)   r   ra   rb   r   rC   rD   r   rd   r   )r+   r*   nowsecsnonstandard_expectationsrf   rg   msgs          r   rB   zStrftimeTest.strftest2   s%   c#hh--$h :dl3//002IJ#s1vs1vAs
&DD!4$'>#34 #s1vs1vAs
&DDjQ53q6>#QR8&s1v.0HI53q6>#?@-&$,AA	)RR;#a&#a&!117;7<=)#s1vs1vs1v&>>
KFc!fSj)<>'$
 0 * 	H 	HAqtS11    tttQqTTT3v;;;0? #JJJ x	!A$	22F;; H? REQqTTT1Q444PQQQ HvayC//? )EaDDD!A$$$( ) ) ) ? HEaDDD!A$$$( ) ) )E1vvFGGG)	H 	Hs   =E
F,#?F''F,N)__name__
__module____qualname__r,   r:   rM   rA   rB   r	   r   r   r   r       se          ,> > >$ $ $".8 .8 .8`0H 0H 0H 0H 0Hr   r   c                   $    e Zd ZdZd Zd Zd ZdS )
Y1900TestszA limitation of the MS C runtime library is that it crashes if
    a date before 1900 is passed with a format string containing "%y"
    c                 N   d}t           j        dk    st           j                            d          rJ|                     t                    5  t          j        d|           d d d            d S # 1 swxY w Y   d S |                     t          j        d|          d           d S )N)	ik  r   r   r   r   r   r   r   r   win32)aixsunossolarisrW   99)rE   rF   
startswithassertRaisesrb   r    ra   assertEqual)r+   ts     r   test_y_before_1900zY1900Tests.test_y_before_1900   s    *LG##<""#>?? $"":.. ' 'dA&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' T]433T:::::s   A//A36A3c                 X    |                      t          j        dd          d           d S )NrW   )	il  r   r   r   r   r   r   r   r   00r   r    ra   r+   s    r   test_y_1900zY1900Tests.test_y_1900   ;    M$ >??	G 	G 	G 	G 	Gr   c                 X    |                      t          j        dd          d           d S )NrW   )	i  r   r   r   r   r   r   r   r   13r   r   s    r   test_y_after_1900zY1900Tests.test_y_after_1900   r   r   N)rs   rt   ru   __doc__r   r   r   r	   r   r   rw   rw      sS         ; ; ;G G GG G G G Gr   rw   __main__)r   r\   rE   r   testr   r    unittestr   r   TestCaser   rw   rs   mainr	   r   r   <module>r      s     



 				          

 
 
SH SH SH SH SH8$ SH SH SHlG G G G G" G G G. zHMOOOOO r   