a
    Pf>                     @   sh  d dl Z d dlmZmZmZmZ d dlZd dlZd dlmZm	Z	m
Z
 d dlZd dlZd dlZd dlmZ d dlmZ d dlmZ d dlmZmZmZmZmZ G dd	 d	ZG d
d dZG dd dZG dd dZG dd dZG dd dZ dd Z!ej"#dddgdd Z$dd Z%ej"#dddgd d! Z&d"d# Z'ej"#d$dej(e)d%eegd&d' Z*dS )(    N)datedatetime	timedeltatimezone)gettztzoffsettzutc)NpyDatetimeUnit)PY310)OutOfBoundsDatetime)NANaTPeriod	Timedelta	Timestampc                   @   s  e Zd Zejdeegdd Zejdeegdd Z	dd Z
ejdd	i gd
ddigdddigdddigddddgdddddgddddgddddgddddgddddgd dd!dgd"dd#dgddddgd$dd!d!dgddddgd%dd&dggd'd( Zd)S )*#TestTimestampConstructorUnitKeywordtypc                 C   sL   |d}t |dd}t d}||ks(J t |dd}t d}||ksHJ d S )N   Yunitz
2120-01-01Mz
1982-07-01r   )selfr   valtsexpected r   h/var/www/ai-form-bot/venv/lib/python3.9/site-packages/pandas/tests/scalar/timestamp/test_constructors.py'test_constructor_int_float_with_YM_unit"   s    zKTestTimestampConstructorUnitKeyword.test_constructor_int_float_with_YM_unitc                 C   sR   |d}d| d}t jt|d t|dd W d    n1 sD0    Y  d S )Nl    `n1! zcannot convert input z with the unit 'D'matchDr   pytestraisesr   r   )r   r   r   msgr   r   r   ;test_construct_from_int_float_with_unit_out_of_bound_raises/   s    z_TestTimestampConstructorUnitKeyword.test_construct_from_int_float_with_unit_out_of_bound_raisesc                 C   s|   d}t jt|d tddd W d    n1 s40    Y  t jt|d tddd W d    n1 sn0    Y  d S )Nz9Conversion of non-round float with unit=[MY] is ambiguousr    g     b@r   r   r   r$   r%   
ValueErrorr   r   r&   r   r   r   4test_constructor_float_not_round_with_YM_unit_raises8   s
    *zXTestTimestampConstructorUnitKeyword.test_constructor_float_not_round_with_YM_unit_raiseszvalue, check_kwargsl    Bm@ig jr
Cr   usg  `kBmsg  6Asi*  r"   r   )r   hgb6Ai  i  )r   r,   nsg  6Ai  )r   r,   g `kBi  gyr
Cg W`kBg(jr
C   g@s
Ci  g) `kBg    f@   c                 C   s   ddd}||fi | d S )N   r   c                 S   s   t | |d}|jdksJ |jdks(J |jdks6J |j|ksDJ |dkrx|jdksZJ |j|kshJ |j|ksJ n*|jdksJ |jdksJ |jdksJ |j|ksJ d S )Nr     r3   r"   r   )	r   yearmonthdayhourminutesecondmicrosecond
nanosecond)valuer   r/   r.   r,   r0   stampr   r   r   check^   s    zKTestTimestampConstructorUnitKeyword.test_construct_with_unit.<locals>.check)Nr3   r3   r   r   r   )r   r=   Zcheck_kwargsr?   r   r   r   test_construct_with_unitB   s    
z<TestTimestampConstructorUnitKeyword.test_construct_with_unitN)__name__
__module____qualname__r$   markparametrizeintfloatr   r'   r+   r@   r   r   r   r   r   !   s<   






r   c                   @   s|  e Zd Zdd Zdd Zejdddgejdd	d
e	d	dde
dddddddejdgdd Zejdddgejdddgdd ZzdedgZW n ejy   dgZY n0 ejdeejddddde
ddddddddddfe
ddddddddddfgd d! Zejddgejd"e
ddddddddd#fe
ddddddddd$fgd%d& ZdS )'#TestTimestampConstructorFoldKeywordc                 C   sB   d}t jt|d tddd W d    n1 s40    Y  d S )Nz5Valid values for the fold argument are None, 0, or 1.r    {      foldr(   r*   r   r   r   -test_timestamp_constructor_invalid_fold_raiser   s    zQTestTimestampConstructorFoldKeyword.test_timestamp_constructor_invalid_fold_raisec              
   C   s^   d}t d}tjt|d. ttddddddd|dd	 W d    n1 sP0    Y  d S )
NzBpytz timezones do not support fold. Please use dateutil timezones.Europe/Londonr      
      r      tzrL   )pytzr   r$   r%   r)   r   r   )r   r&   rT   r   r   r   *test_timestamp_constructor_pytz_fold_raisey   s    
zNTestTimestampConstructorFoldKeyword.test_timestamp_constructor_pytz_fold_raiserL   r   r3   ts_input    P7-f. gP[YѵCr0   2019-10-27 01:30:00+01:00rO   rP   rQ   rR   tzinfoc                 C   sB   d}t jt|d t||d W d    n1 s40    Y  d S )NzCannot pass fold with possibly unambiguous input: int, float, numpy.datetime64, str, or timezone-aware datetime-like. Pass naive datetime-like or build Timestamp from components.r    )rW   rL   r(   )r   rW   rL   r&   r   r   r   (test_timestamp_constructor_fold_conflict   s    zLTestTimestampConstructorFoldKeyword.test_timestamp_constructor_fold_conflictrT   dateutil/Europe/LondonNc              	   C   s0   t ddddd||d}|j}|}||ks,J d S )NrO   rP   rQ   r3   rR   )r5   r6   r7   r8   r9   rT   rL   r   rL   )r   rT   rL   r   resultr   r   r   r   &test_timestamp_constructor_retain_fold   s    zJTestTimestampConstructorFoldKeyword.test_timestamp_constructor_retain_foldrN   zts_input,fold_out)rX   r   )l    pFs. r3   )rY   r   )z2019-10-27 01:30:00+00:00r3   rK   c                 C   s&   t ||d}|j}|}||ks"J d S )NrT   r^   )r   rT   rW   Zfold_outr   r_   r   r   r   r   0test_timestamp_constructor_infer_fold_from_value   s    zTTestTimestampConstructorFoldKeyword.test_timestamp_constructor_infer_fold_from_valuezts_input,fold,value_outl    RzweW, l    v$iW, c                 C   s(   t |||d}|j}|}||ks$J d S )NrS   r   _value)r   rT   rW   rL   Z	value_outr   r_   r   r   r   r   0test_timestamp_constructor_adjust_value_for_fold   s    zTTestTimestampConstructorFoldKeyword.test_timestamp_constructor_adjust_value_for_fold)rA   rB   rC   rM   rV   r$   rD   rE   np
datetime64r   r   utcr\   r`   zoneinfoZZoneInfoZ_tzsZZoneInfoNotFoundErrorrb   re   r   r   r   r   rH   q   sT   	

	rH   c                   @   s~   e Zd Zdd Zdd Zejdg ddd Zejd	i d
didddgdd Z	dd Z
ejdg ddd ZdS )3TestTimestampConstructorPositionalAndKeywordSupportc              	   C   s  t rdnd}tjt|d tdd W d    n1 s:0    Y  d}tjt|d tddd W d    n1 sx0    Y  tjt|d tddd W d    n1 s0    Y  d	}tjt|d tddd W d    n1 s0    Y  tjt|d tddd
 W d    n1 s,0    Y  ttdddttdksXJ ttdddddddttdksJ d S )Nz5'NoneType' object cannot be interpreted as an integerzan integer is requiredr    r4   r3   month must be in 1..12r      day is out of range for month         r2   20151112rJ      ?B 2015-11-12 01:02:03.999999)r
   r$   r%   	TypeErrorr   r)   reprr*   r   r   r   test_constructor_positional   s(    (***,"zOTestTimestampConstructorPositionalAndKeywordSupport.test_constructor_positionalc              
   C   s  d}t jt|d tddd W d    n1 s40    Y  d}t jt|d tdddd W d    n1 st0    Y  t jt|d tdd	dd W d    n1 s0    Y  d
}t jt|d tdddd W d    n1 s0    Y  t jt|d tdddd W d    n1 s.0    Y  ttddddttdks\J ttddddddddttdksJ d S )Nz@function missing required argument 'day'|Required argument 'day'r    r4   r3   r5   r6   rk   r   )r5   r6   r7   rl   rm   rn   ro   rp   r2   rq   rJ   rr   rs   )r5   r6   r7   r8   r9   r:   r;   rt   )r$   r%   ru   r   r)   rv   r*   r   r   r   test_constructor_keyword   s:    *,,,.

zLTestTimestampConstructorPositionalAndKeywordSupport.test_constructor_keywordargr5   r6   r7   r8   r9   r:   r;   r<   c                 C   sL   |di}d}t jt|d tdi | W d    n1 s>0    Y  d S )Nr3   z-Cannot pass a date attribute keyword argumentr    2010-10-10 12:59:59.999999999)r|   r(   )r   rz   kwargr&   r   r   r   )test_invalid_date_kwarg_with_string_input  s    z]TestTimestampConstructorPositionalAndKeywordSupport.test_invalid_date_kwarg_with_string_inputkwargsr5     r3   rx   c                 C   sV   d}d}d ||g}tjt|d tf i | W d    n1 sH0    Y  d S )NzCfunction missing required argument '(year|month|day)' \(pos [123]\)z<Required argument '(year|month|day)' \(pos [123]\) not found|r    )joinr$   r%   ru   r   )r   r   Zmsg1Zmsg2r&   r   r   r    test_constructor_missing_keyword%  s
    zTTestTimestampConstructorPositionalAndKeywordSupport.test_constructor_missing_keywordc                 C   s0   t dddtjd}t dtjd}||ks,J d S )Nr   r2      rZ   
2020-12-31)r   r   rh   )r   r   r   r   r   r   'test_constructor_positional_with_tzinfo1  s    z[TestTimestampConstructorPositionalAndKeywordSupport.test_constructor_positional_with_tzinfokwd)r<   r;   r:   r9   c           	      C   sx   |dkr t jjdd}|| |di}tddtji|}|d di}tf i |}tdtjd	| }||kstJ d S )
Nr<   zGH#45307)reason   )r   r2   r   r[   r.   r   ra   )r$   rD   ZxfailZapplymarkerr   r   rh   r   )	r   r   requestrD   r   r   Z	td_kwargstdr   r   r   r   5test_constructor_positional_keyword_mixed_with_tzinfo7  s    
ziTestTimestampConstructorPositionalAndKeywordSupport.test_constructor_positional_keyword_mixed_with_tzinfoN)rA   rB   rC   rw   ry   r$   rD   rE   r~   r   r   r   r   r   r   r   rj      s   "

rj   c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )$TestTimestampClassMethodConstructorsc                 C   sJ   d}d}d}t jt|d t|| W d    n1 s<0    Y  d S )Nz%Y%m%d-%H%M%S-%f%zz20190129-235348-000001+0000z)Timestamp.strptime\(\) is not implementedr    )r$   r%   NotImplementedErrorr   strptime)r   fmtr   r&   r   r   r   test_constructor_strptimeL  s
    z>TestTimestampClassMethodConstructors.test_constructor_strptimec                 C   sN   t d}tddd}t ddd}||ks0J ||ks<J t|t sJJ d S )Nz2000-01-03 00:00:00r4   r3   )r   r   fromisocalendar
isinstance)r   Zexpected_timestampZexpected_stdlibr_   r   r   r    test_constructor_fromisocalendarU  s    zETestTimestampClassMethodConstructors.test_constructor_fromisocalendarc                 C   s   t ddd}t| }||ks&J | | ks:J tj| dd}tddd|ks`J | | kstJ t dddd	d	}t| }| |ksJ td
dd}| }tj| dd}| |ksJ d S )Nr4   r3   
US/Easternra   z
2000-01-01i  r      r   z	2011-4-16)r   r   fromordinal	toordinalto_pydatetime)r   baser   dtr>   Zdt_tzr   r   r   test_constructor_fromordinal^  s    zATestTimestampClassMethodConstructors.test_constructor_fromordinalc                 C   s   t d}t  }t }t ddd}t jdd}tdd}t|| |k sNJ t|| |k sbJ t|| |k svJ t|d |d  |k sJ d S )Nnowr   ra   r3   seconds)r   r   r   r   abstz_localizer   ts_from_stringts_from_methodZts_datetimeZts_from_string_tzZts_from_method_tzdeltar   r   r   test_nowt  s"    
z-TestTimestampClassMethodConstructors.test_nowc                 C   s   t d}t  }t }t ddd}t jdd}tdd}t|| |k sNJ t|| |k sbJ t|| |k svJ t|d |d  |k sJ d S )Ntodayr   ra   r3   r   )r   r   r   r   r   r   r   r   r   r   
test_today  s"    
z/TestTimestampClassMethodConstructors.test_todayN)rA   rB   rC   r   r   r   r   r   r   r   r   r   r   I  s
   		r   c                   @   s6   e Zd Zdd Zdd Zejdddgdd	 Zd
S ) TestTimestampResolutionInferencec                 C   s   t d}|jdksJ d S )Nz01:01:01.111r-   r   r   r   r   r   r   r   test_construct_from_time_unit  s    z>TestTimestampResolutionInference.test_construct_from_time_unitc                 C   s  t d}|jdksJ t d}|jdks,J t d}|jdksBJ t d}|jdksXJ t d}|jdksnJ t d}|jdksJ t d	}|jd
ksJ t d}|jdksJ t d}|t dksJ |jd
ksJ t d}|jdksJ t d}|jdksJ d S )Nz
01/30/2023r.   Z2015Q1z2016-01-01 1:30:01 PMz2016 June 3 15:25:01.345r-   z	300-01-01z300 June 1:30:01.300z"01-01-2013T00:00:00.000000000+0000r0   z2016/01/02 03:04:05.001000 UTCr,   z%01-01-2013T00:00:00.000000002100+0000z"01-01-2013T00:00:00.000000002+0000z2020-01-01 00:00+00:00z2020-01-01 00+00:00r   r   r   r   r   test_constructor_str_infer_reso  s.    z@TestTimestampResolutionInference.test_constructor_str_infer_resomethodr   r   c                 C   s6   t t| }t|}|j|j  kr,dks2n J d S )Nr,   )getattrr   r   )r   r   r   r   r   r   r   test_now_today_unit  s    z4TestTimestampResolutionInference.test_now_today_unitN)	rA   rB   rC   r   r   r$   rD   rE   r   r   r   r   r   r     s   +r   c                   @   s  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zejdeedddddddddedddddddddedddddddddd 	edddddddd!dd	edddddddejdd"	gd#d$ Zejd%d&d'gd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zejjd2d3 Zejd4d5d6gd7d8 Zd9d: Zd;d< Zejd=d>d?gd@dA Zejd4dBdCgdDdE Z ejdFeegdGdH Z!dIdJ Z"dKdL Z#dMdN Z$dOdP Z%dQdR Z&ejdSe'dTe(dTdTdUgdVdW Z)d!S )XTestTimestampConstructorsc                 C   s>   d}t jt|d td W d    n1 s00    Y  d S )NzFParsing datetimes with weekday but no day information is not supportedr    z2023 Sept Thur(   r*   r   r   r   test_weekday_but_no_day_raises  s    z8TestTimestampConstructors.test_weekday_but_no_day_raisesc                 C   s:   t jtdd td W d    n1 s,0    Y  d S )Nzgives an invalid tzoffsetr    z200622-12-31r(   r   r   r   r   )test_construct_from_string_invalid_raises  s    zCTestTimestampConstructors.test_construct_from_string_invalid_raisesc                 C   s\   t d}|jdksJ t d}|jdks,J t d}|jdksBJ t d}|jdksXJ d S )	Nz2016-01-01 04:05:06-01:00r.   z2016-01-01 04:05:06.000-01:00r-   z 2016-01-01 04:05:06.000000-01:00r,   z#2016-01-01 04:05:06.000000001-01:00r0   r   r   r   r   r   2test_constructor_from_iso8601_str_with_offset_reso  s    zLTestTimestampConstructors.test_constructor_from_iso8601_str_with_offset_resoc                 C   s&   t ddd}t|}|jdks"J d S )N  	   r3   r.   )r   r   r   )r   objr   r   r   r   &test_constructor_from_date_second_reso  s    z@TestTimestampConstructors.test_constructor_from_date_second_resoc                 C   sF   t d}d}t||d}t||}||ks4J |jdksBJ d S )Nz1970-01-01 05:00:00z	UTC+05:00ra   r1   )rf   rg   r   r   r8   )r   r   Ztzstrr   Zaltr   r   r   #test_constructor_datetime64_with_tz  s    
z=TestTimestampConstructors.test_constructor_datetime64_with_tzc                 C   s  d}t dddd}d}t| d |ks0J |||fdt dddd	|d
 fdt ddddddd|d fdtd|d fg}ddtjdfdddtddftj	
d ddfg}|D ]$\}}}t|t|fD ]>}	|	d}	|	dj|ksJ t|	}	|	dj|ksJ q|D ]\}
}t||
dt||
dfD ]}	|	d}	||d d  }|	dj|kshJ t|	}	|	dj|ksJ |
d urt|	d}	nt|	dd}	||d d  }|	dj|ks4J q4qqd S )Nz2014-07-01 09:00     r3   r        t  ʚ;z2014-07-01 10:00rP        qaz2014-07-01 09:00:00.000008000r      @  z2014-07-01 09:00:00.000000005r1   Nr   UTCr   
Asia/Tokyor   r   zdateutil/US/PacificiLPF  r0   ra   i  r   )r   calendartimegm	timetupler   rU   rh   FixedOffsetdateutilrT   r   as_unitrd   
tz_convert)r   base_strbase_dtbase_expectedtests	timezonesdate_strZdate_objr   r_   rT   offsetexpected_tzexpected_utcr   r   r   test_constructor  s^    

z*TestTimestampConstructors.test_constructorc                 C   s  d}t dddd}d}t| d |ks0J ||fd|d	 fd
|d fd|d fg}ddtjdfdddtddftj	d ddfg}|D ]\}}t
|fD ]4}|dj|ksJ t
|}|dj|ksJ q|D ]r\}	}
t
||	d}|}|dj|ksJ t
|}|dj|ks&J t
|d}|}|dj|ksJ qqt
ddd}|jt
djksrJ d}t||ksJ |tt|ksJ t
ddd}|jt
djksJ d}t||ksJ |tt|ksJ t
d d!d}|jt
d"jksJ d#}t||ks$J |tt|ks:J t
d$d%d}|jt
d"jks\J d&}t||ksrJ |tt|ksJ d S )'Nz2014-07-01 11:00:00+02:00r   r   r3   r   r   r   z2014-07-01 12:00:00+02:00r   z#2014-07-01 11:00:00.000008000+02:00r   z#2014-07-01 11:00:00.000000005+02:00r1   r   r   r   r   r   r   r   r   r   r0   ra   r   z2013-11-01 00:00:00-0500zAmerica/Chicagoz2013-11-01 05:00z;Timestamp('2013-11-01 00:00:00-0500', tz='America/Chicago')r   z6Timestamp('2013-11-01 14:00:00+0900', tz='Asia/Tokyo')z2015-11-18 15:45:00+05:45zAsia/Katmanduz2015-11-18 10:00z9Timestamp('2015-11-18 15:45:00+0545', tz='Asia/Katmandu')z2015-11-18 15:30:00+05:30Asia/Kolkataz8Timestamp('2015-11-18 15:30:00+0530', tz='Asia/Kolkata'))r   r   r   r   rU   rh   r   r   rT   r   r   r   rd   r   rv   eval)r   r   r   r   r   r   r   r   r_   rT   r   r   r   r   r   r   "test_constructor_with_stringoffsetS  sh    


z<TestTimestampConstructors.test_constructor_with_stringoffsetc                 C   s   d}t jt|d ttd W d    n1 s40    Y  d}t jt|d ttd W d    n1 sr0    Y  d S )NzCannot convert inputr    rJ   zCannot convert Periodz
1000-01-01)r$   r%   ru   r   slicer)   r   r*   r   r   r   test_constructor_invalid  s    *z2TestTimestampConstructors.test_constructor_invalidc                 C   s   d}t jt|d tddd W d    n1 s40    Y  d}t jt|d  tdtjdd W d    n1 sv0    Y  d	}t jt|d td
d W d    n1 s0    Y  d S )NzJArgument 'tzinfo' has incorrect type \(expected datetime.tzinfo, got str\)r    z
2017-10-22r   rZ   zat most one ofr   )r[   rT   zHCannot pass a date attribute keyword argument when passing a date stringz
2012-01-01
US/Pacific)r$   r%   ru   r   r)   rU   rh   r*   r   r   r   test_constructor_invalid_tz  s    *.z5TestTimestampConstructors.test_constructor_invalid_tzc              
      s   t dddddt dddtjdt dddtjdt tdddtjdt tdddddt tdddtjdg t fd	d
 D sJ d S )Ni  rP      r   )r5   r6   r7   rT   r5   r6   r7   r[   rZ   ra   c                 3   s   | ]}| d  kV  qdS )r   Nr   ).0r   Zstampsr   r   	<genexpr>      zJTestTimestampConstructors.test_constructor_tz_or_tzinfo.<locals>.<genexpr>)r   rU   rh   r   allr   r   r   r   test_constructor_tz_or_tzinfo  s    z7TestTimestampConstructors.test_constructor_tz_or_tzinfor_   r4   r3   rJ   rr   r   r1      )r<   r{   r   )	r5   r6   r7   r8   r9   r:   r;   r<   rT   N)rT   r<   c              	   C   s<   t tddddddd|jd}|tdd	 }||ks8J d S )
Nr4   r3   rJ   rr   r   r1   r   ra   )nanoseconds)r   r   rT   r   r   r_   r   r   r   r   test_constructor_nanosecond  s     z5TestTimestampConstructors.test_constructor_nanosecondzZZ0ZZ00c                 C   sJ   d| }t jt|d td|  W d    n1 s<0    Y  d S )NzAUnknown datetime string format, unable to parse: 2014-11-02 01:00r    z2014-11-02 01:00r(   )r   r   r&   r   r   r   %test_constructor_invalid_Z0_isostring  s    
z?TestTimestampConstructors.test_constructor_invalid_Z0_isostringc                 C   s   t tjjd }tjt|d  ttjjd  W d    n1 sD0    Y  t tjjd }tjt|d  ttjjd  W d    n1 s0    Y  d S )NrJ   r    )strr   maxrd   r$   r%   r   minr*   r   r   r    test_out_of_bounds_integer_value  s    .z:TestTimestampConstructors.test_out_of_bounds_integer_valuec                 C   s  t dd}t tjd| }t tjd}t| t| tjj	}t|| j
|ksfJ t|| j
|ks|J t dd}t dd}d}tjt|d t| W d    n1 s0    Y  tjt|d t| W d    n1 s0    Y  d S )	Nr3   ztimedelta64[us]zM8[us]z-292277022657-01-27T08:29mz292277026596-12-04T15:31zOut of boundsr    )rf   Ztimedelta64Zastyperg   r   r   r   r	   Z	NPY_FR_usr=   _cresor$   r%   r)   )r   Zone_usZ	min_ts_usZ	max_ts_usZus_valZtoo_lowZtoo_highr&   r   r   r   test_out_of_bounds_value  s    &z2TestTimestampConstructors.test_out_of_bounds_valuec                 C   s   d}t jt|d tdd W d    n1 s60    Y  t jt|d tdd W d    n1 sr0    Y  td}|jdksJ td}|jdksJ d S )Nz,Cannot cast .* to unit='ns' without overflowr    z
1676-01-01r0   z
2263-01-01r.   )r$   r%   r)   r   r   r   )r   r&   r   r   r   r   test_out_of_bounds_string$  s    ,,z3TestTimestampConstructors.test_out_of_bounds_stringc                 C   s>   d}t jt|d td W d    n1 s00    Y  d S )Nz7Out of bounds nanosecond timestamp: 2262-04-11 23:47:16r    z2262-04-11 23:47:16.854775808r#   r*   r   r   r   test_barely_out_of_bounds1  s    z3TestTimestampConstructors.test_barely_out_of_boundsc              
   C   s  d}d}|D ]R}|D ]H}t ||}t|}|dv rJ|j|dks\J q|jtjjksJ qqt 	t j
}d}|jd |jfD ]P}	dD ]F}t |	|}tjt|d t| W d    q1 s0    Y  qqd	}
|
D ]"}|D ]}t ||}t| qqd S )
N)z
1677-09-21z
2262-04-12)r"   r/   r   r.   r-   r,   )r.   r-   r,   i8zOut of bounds second timestamp:r3   )r"   r/   r   r    )z
1677-09-23z
2262-04-11)rf   rg   r   rd   viewr   r	   ZNPY_FR_sr=   ZiinfoZint64r   r   r$   r%   r   )r   Zout_of_bounds_datesZ
time_unitsZdate_stringr   Zdt64r   infor&   r=   Zin_bounds_datesr   r   r    test_bounds_with_different_units9  s*    *z:TestTimestampConstructors.test_bounds_with_different_unitsrz   z	001-01-01z
0001-01-01c                 C   s   d}t jt|d t|d W d    n1 s60    Y  t|}|jdksVJ |j|j  krz|j  krzdksn J d S )Nz=Cannot cast 0001-01-01 00:00:00 to unit='ns' without overflowr    r0   r.   r3   )	r$   r%   r   r   r   r   r5   r6   r7   )r   rz   r&   r   r   r   r   %test_out_of_bounds_string_consistencyZ  s    ,z?TestTimestampConstructors.test_out_of_bounds_string_consistencyc                 C   s   t t j d S N)r   r   r   r   r   r   test_min_valide  s    z(TestTimestampConstructors.test_min_validc                 C   s   t t j d S r  )r   r   r   r   r   r   test_max_validi  s    z(TestTimestampConstructors.test_max_validr   z+0300z+0200c                 C   s0   t d| dd}t |d}||ks,J d S )Nz2016-10-30 03:00:00zEurope/Helsinkira   )r   r   )r   r   r   r_   r   r   r   !test_construct_timestamp_near_dstm  s    z;TestTimestampConstructors.test_construct_timestamp_near_dstz2013/01/01 00:00:00+09:00z2013-01-01 00:00:00+09:00c                 C   s2   t |}t tdddtdd}||ks.J d S )Ni  r3   i  ra   )r   r   rU   r   )r   rz   r_   r   r   r   r   +test_construct_with_different_string_formatt  s    zETestTimestampConstructors.test_construct_with_different_string_formatboxc                 C   s   dddt jd}d}tjt|d& t|f i |dd W d    n1 sN0    Y  d}tjt|d, t|f i |t dd W d    n1 s0    Y  d S )	N  r3   r   z#Cannot pass a datetime or Timestampr    r   ra   rZ   )rU   rh   r$   r%   r)   r   r   )r   r  r   r&   r   r   r   *test_raise_tz_and_tzinfo_in_datetime_input}  s    4zDTestTimestampConstructors.test_raise_tz_and_tzinfo_in_datetime_inputc                 C   s>   t tdddt d}t tdddt }||ks:J d S )Nr  r3   ra   )r   r   r   r   r   r   r   r   *test_dont_convert_dateutil_utc_to_pytz_utc  s    zDTestTimestampConstructors.test_dont_convert_dateutil_utc_to_pytz_utcc                 C   s@   G dd dt }|ddd}t|}tddd}||ks<J d S )Nc                   @   s   e Zd ZdS )zSTestTimestampConstructors.test_constructor_subclassed_datetime.<locals>.SubDatetimeN)rA   rB   rC   r   r   r   r   SubDatetime  s   r
  r4   r3   )r   r   )r   r
  datar_   r   r   r   r   $test_constructor_subclassed_datetime  s
    z>TestTimestampConstructors.test_constructor_subclassed_datetimec                 C   sJ   t ddd}|jtju sJ |jdks*J t dd}|jdksFJ d S )Nz3/11/2012 05:00rh   ra   r1   )r   r[   r   rh   r8   r   )r   Z	utc_stampr   r   r   !test_timestamp_constructor_tz_utc  s
    z;TestTimestampConstructors.test_timestamp_constructor_tz_utcc                 C   s2   t d d}td|d}t| }||ks.J d S )Ni   z3/11/2012 04:00ra   )r   r   r   )r   r[   r   r_   r   r   r   #test_timestamp_to_datetime_tzoffset  s    
z=TestTimestampConstructors.test_timestamp_to_datetime_tzoffsetc              	   C   s  dD ]j}t d|d}t d|}||ks.J d}tjtj|d t d|d W d    q1 sd0    Y  qt ddd}t dd}||ksJ d	}tjtj|d t d	dd W d    n1 s0    Y  t d
}|dd}t ddd}||ksJ t ddd}t ddd}||ks.J t ddd}t ddd}||ksTJ d	}tjtj|d t d	dd W d    n1 s0    Y  t ddd}t |dj	}|dd}||ksJ t ddd}t ddd}||ksJ d S )N)zEurope/BrusselszEurope/Praguez2015-10-25 01:00ra   z.Cannot infer dst time from 2015-10-25 02:00:00r    z2015-10-25 02:00z2017-03-26 01:00zEurope/Parisz2017-03-26 02:00z2015-11-18 10:00:00r   r   z2015-11-18 15:30:00+0530z2017-03-26 00:00z2017-03-26 00:00:00+0100z2017-03-26 01:00:00+0100z2017-03-26 02:00:00+0100r0   z2017-03-26 03:00z2017-03-26 03:00:00+0200)
r   r   r$   r%   rU   ZAmbiguousTimeErrorZNonExistentTimeErrorr   r   rd   )r   rT   r_   r   r&   Znaiver   r   r   ,test_timestamp_constructor_near_dst_boundary  sB    ,*,zFTestTimestampConstructors.test_timestamp_constructor_near_dst_boundaryrT   r   zdateutil/US/Easternc                 C   s@   t tddd|d}t d|d}|j|jks0J ||ks<J d S )Nr   rr   rp   ra   z	3/11/2012)r   r   r8   )r   rT   r_   r   r   r   r   )test_timestamp_constructed_by_date_and_tz  s    zCTestTimestampConstructors.test_timestamp_constructed_by_date_and_tz)*rA   rB   rC   r   r   r   r   r   r   r   r   r   r   r$   rD   rE   r   r   rU   r   r   r   r   r   r   r   Z
skip_ubsanr   r   r  r  r  r  r  r	  r  r  r  r  r   r   r  r   r   r   r   r     s   
ET


	!
 





2	r   c                  C   s,   t ddd} | j}t | j}||ks(J d S )Nl     !F r]   ra   rc   )r   r   r_   r   r   r   test_constructor_ambiguous_dst  s    
r  epochl   ?2\BT, l   ?2\BT, c                 C   sD   t | dd}|j|}tdd}t |j| ks4J ||ks@J d S )Nzdateutil/America/Los_Angelesra   r   r   )r   rT   dstr   rd   )r  r   r_   r   r   r   r   "test_constructor_before_dst_switch  s
    
r  c                  C   s    t d} t | }|| u sJ d S )Nz2017-01-01T12r   )r   r_   r   r   r   #test_timestamp_constructor_identity  s    r  nanoi  c                 C   sB   t jtdd  tddd| d W d    n1 s40    Y  d S )Nznanosecond must be in 0..999r    i  r3   )r5   r6   r7   r<   r(   )r  r   r   r   test_timestamp_nano_range  s    r  c                  C   sv   t dddj} | dksJ d}t d}tjt|d |j W d    n1 sP0    Y  |jd} | d	ksrJ d S )
Nz
1800-01-01r.   r   l  'pS zCannot convert Timestamp to nanoseconds without overflow. Use `.asm8.view\('i8'\)` to cast represent Timestamp in its own unit \(here, s\).$z
0300-01-01r    r   ldW
1 )r   r=   r$   r%   OverflowErrorZasm8r   )r_   r&   r   r   r   r   test_non_nano_value  s    $r  na_valuer   c                 C   s   t | }t}||u sJ d S r  )r   r   )r  r_   r   r   r   r   #test_timestamp_constructor_na_value'  s    r  )+r   r   r   r   r   ri   Zdateutil.tzr   r   r   r   numpyrf   r$   rU   Zpandas._libs.tslibs.dtypesr	   Zpandas.compatr
   Zpandas.errorsr   Zpandasr   r   r   r   r   r   rH   rj   r   r   r   r  rD   rE   r  r  r  r  nanrg   r  r   r   r   r   <module>   s<   	PbvY9    

