
    .i-                       d Z ddlZddlmZ ddlmZmZmZmZ ddlm	Z	 ddl
Z
ddlZddlmZ ddlZddlZddlmZ ddlmZmZ dd	lmZmZ dd
lmZmZ ddlmc mZ ddl m!Z! ddl"Z#ddl"m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z, ddl-m.Z/ ddl0m1Z1 ddl2m3Z4 ddl5m6Z6 dZ7erdZ8dZ9ndZ8dZ9 G d d      Z: G d d      Z; G d d      Z< G d d      Z= G d d      Z> G d d       Z? G d! d"      Z@ G d# d$      ZA G d% d&      ZB ej                  g d'(      d)        ZDej                  d*        ZE G d+ d,      ZF G d- d.      ZGd/ ZHej                  j                  d0ej                  eLg      d1        ZMej                  j                  d2d3d4g      ej                  j                  d5g d6d7fg d8d9fgd:d;g<      d=               ZNd> ZOd? ZPej                  j                  d@dAe6e6dBz   e6dCz   g      dD        ZQdE ZRdF ZSdG ZTej                  j                  dHdIdJg      ej                  j                  dKd;dLg      dM               ZUdN ZVdO ZWdP ZXdQ ZYdR ZZdS Z[dT Z\dU Z]dV Z^dW Z_dX Z`dY ZadZ Zbd[Zc e)ec      Zdej                  j                  d\      ej                  j                  d]ec e)ec      gd^ <      ej                  j                  d_ecdd` edj                  d      edj                         edj                  edj                   eiedj                        gda <      ej                  j                  dbdIdJg      dc                             Zjdd Zkde Zly)fztest to_datetime    N)deque)datedatetime	timedeltatimezone)Decimal)parse)tslib)iNaTparsing)PY314WASM)OutOfBoundsDatetimeOutOfBoundsTimedelta)is_datetime64_ns_dtype)		DataFrameDatetimeIndexIndexNaTSeries	Timestamp
date_rangeisnato_datetime)DatetimeArray)	datetimes)start_caching_ata_  You might want to try:\n    - passing `format` if your strings have a consistent format;\n    - passing `format=\'ISO8601\'` if your strings are all ISO8601 but not necessarily in exactly the same format;\n    - passing `format=\'mixed\'`, and the format will be inferred for each element individually. You might want to use `dayfirst` alongside this.z, not 99zIday \d{1,2} must be in range 1\.\.\d{1,2} for month \d{1,2} in year \d{4} zday is out of range for monthc                   ~   e Zd Zd Zej
                  j                  dd ed       ed       ed      ggd ed       ed       ed	      ggg      d
        Zej
                  j                  dg dg dg dg dg dg dg      d        Z	d Z
d Zd Zd Zd Zej
                  j                  dg dddej                   gddegg dg dddej                   gddegg d g      d!        Zej
                  j                  d"dej                   d#d$g ed      ej                   ej                   ej                   ggdd#d$ej                   g ed      ej                   ej                   ej                   ggd%ej                   d&d'g ed(      ej                   ej                   ej                   ggd%d&ej                   d'g ed(      ej                   ej                   ej                   ggg      d)        Zej
                  j                  d*ej*                  gd+d,gfej*                  gd-d,gfej*                  d.gd+d,d/gfd0ej*                  gd1d2d,gfd0ej*                  gd3d4d,gfd-ej                   ej*                  gd-g d5fd-ej                   ej*                  gd6g d5fg      d7        Zd8 Zd9 Zd: Zej
                  j                  d;d<d= ed>      gd?d@ edA      gdBdC edD      g ej4                  dEdF edG      ej
                  j7                   ej:                         dH   dIv dJdKL      M       ej4                  dNdF edO      ej
                  j7                   ej:                         dH   dIv dJdKL      M       ej4                  dPdQ edR      ej
                  j7                   ej:                         dH   dIv dJdKL      M      g      dS        Zej@                  dT        Z!ej
                  j                  ddU edVdWdX      fdY edVdXdW      fdZ edVdWdXd[      fd\ edVdXdWd[      fd] edVdWdXd[d^      fd_ edVdXdWd[d^      fd` edVdWdXd[d^da      fdb edVdXdWd[d^da      fdc edVdWdXd[d^dadd      fde edVdXdWd[d^dadd      fdf edVdWdXd[d^dadddgh      fdi edVdXdWd[d^dadddgh      fg      dj        Z"ej
                  j                  dkg dl      dm        Z#ej
                  j                  dng dog dpg      dq        Z$ej
                  j                  drdsdtgduz   edvdwh      gduz  gdxdygduz   edv e% e&dz{            |      gduz  gd}d~gduz   edv e% e&dz{            |      gduz  gd}ddg edv e% e&dH{            |       edv e% e&dH{            |      ggg      d        Z'ej
                  j                  drdsg d edvdwh       edvdh       edvdh      ggd}d~dg edv e% e&dz{            |       edv e% e&d{            |      ggg      d        Z(d Z)ej
                  j                  dg d      d        Z*d Z+y-)TestTimeConversionFormatsc                     t        j                  g t              }|j                  |       t	        |      }t	        g       }t        j                  ||       y )Ndtype)write)nparrayobjectsetflagsr   tmassert_index_equal)selfwritablearrresultexpecteds        a/var/www/app/trading-bot/venv/lib/python3.12/site-packages/pandas/tests/tools/test_to_datetime.pytest_to_datetime_readonlyz3TestTimeConversionFormats.test_to_datetime_readonlyK   sC    hhr(8$S!r?
fh/    zformat, expected%d/%m/%Y200001012000020120000301%m/%d/%Y2000010220000103c                 p     |g d      }t        |||      } ||      }t        j                  ||       y )N)1/1/20001/2/20001/3/2000formatcache)r   r)   assert_equal)r+   r@   index_or_seriesr?   r/   valuesr.   s          r0   test_to_datetime_formatz1TestTimeConversionFormats.test_to_datetime_formatS   s5     !!EFVF%@"8,
)r2   zarg, expected, format)r;   r4   r3   )r;   r4   r7   )r<   r5   r3   )r<   r8   r7   )r=   r6   r3   )r=   r9   r7   c                 D    t        |||      }t        |      }||k(  sJ y Nr>   r   r   )r+   r@   argr/   r?   r.   s         r0   test_to_datetime_format_scalarz8TestTimeConversionFormats.test_to_datetime_format_scalarf   s*     Su=X&!!!r2   c                 V   t        ddgdgdz  z         }t        |j                  t              D cg c]  }t        |       c}      }t	        |d|      }t        j                  ||       t	        |j                  t              d|      }t        j                  ||       y c c}w )N$.9G.   %Y%m%dr>   r   applystrr   r   r)   assert_series_equalr+   r@   serxr/   r.   s         r0    test_to_datetime_format_YYYYMMDDz:TestTimeConversionFormats.test_to_datetime_format_YYYYMMDDv   s    h)XJN:;3@A9Q<@AS?
vx0SYYs^HEJ
vx0 As   B&c                    t        ddgdgdz  z   d      }t        t        d      t        d      gt        d      gdz  z   d      }t        j                  |d	<   t        j                  |d	<   t	        |d
|      }t        j                  ||       |j                  t              }d|d	<   t        j                  t        d      5  t	        |d
|       d d d        y # 1 sw Y   y xY w)NrK   rL   rM   floatr"   1980122219810105M8[us]   rN   r>   natzBunconverted data remains when parsing with format "%Y%m%d": ".0". match)r   r   r%   nanr   r)   rR   rP   rQ   pytestraises
ValueError)r+   r@   rT   r/   r.   ser2s         r0   )test_to_datetime_format_YYYYMMDD_with_natzCTestTimeConversionFormats.test_to_datetime_format_YYYYMMDD_with_nat   s    h)XJN:'Jz"Ij$9:$%)*

 ffAS?
vx0 yy~Q]]T
 	< XU;	< 	< 	<s   CC(c                 &   t        ddgdgdz  z   d      }t        t        d      t        d      gt        d      gdz  z   d      }t        j                  |d	<   t        j                  |d	<   t	        |d
|      }t        j                  ||       y )Ni| i rM   rX   r"   1980120119810101r[   r\   %Y%mr>   )r   r   r%   r`   r   r)   rR   )r+   r@   rT   r/   r.   s        r0   'test_to_datetime_format_YYYYMM_with_natzATestTimeConversionFormats.test_to_datetime_format_YYYYMM_with_nat   s     ff%14GDz"Ij$9:$%)*

 ffASu=
vx0r2   c                     t        g d      }t        |dd|      }t        t        j                  g dd      d      }t	        j
                  ||       y )	N)3T3irN   raiser?   errorsr@   )z
2012-12-31
2014-12-31z
9999-12-31M8[s]r"   r[   )r   r   r%   r&   r)   rR   r+   r@   rT   r.   r/   s        r0   +test_to_datetime_format_YYYYMMDD_oob_for_nszETestTimeConversionFormats.test_to_datetime_format_YYYYMMDD_oob_for_ns   sM     34S'OHH?wO
 	vx0r2   c                     t        g d      }t        |dd|      }t        g dd      }t        j                  ||       y )N)rl   rm   l   ]'l
F3YHqS rN   coercero   )2012123120141231r   r[   r"   r   r   r)   rR   rs   s        r0   )test_to_datetime_format_YYYYMMDD_coercionzCTestTimeConversionFormats.test_to_datetime_format_YYYYMMDD_coercion   s<     LMS(%P9J
vx0r2   input_s)rY   20010112NrY   r|   )rY   r|   r   )rK   T1NrK   r}   )rK   r}   r   c                     t        t        d      t        d      t        g      }t        t        |d            }t	        j
                  ||       y )NrY   r|   rN   r?   )r   r   r   r   r)   rR   r+   r{   r/   r.   s       r0   *test_to_datetime_format_YYYYMMDD_with_nonezDTestTimeConversionFormats.test_to_datetime_format_YYYYMMDD_with_none   s@    & 9Z0)J2GMNGH=>
vx0r2   zinput_s, expected2001001210019999i]4iT1i{120190813c                 x    t        |      }t        |dd      }t        |      }t        j                  ||       y )NrN   rv   r?   rp   ry   r   s       r0   )test_to_datetime_format_YYYYMMDD_overflowzCTestTimeConversionFormats.test_to_datetime_format_YYYYMMDD_overflow   s5    8 /WXhG(#
vx0r2   zdata, format, expectedz%Y%m%d%H%M%Sr   N20210202202020z2021-02-02 20:20:20201010z%y%m%dz
2020-10-10z%d%m%y
2010-10-20)r   r   r   rN   c                 `    t        ||      }t        |      }t        j                  ||       y Nr   r   r   r)   r*   )r+   datar?   r/   r.   s        r0   test_to_datetime_with_NAz2TestTimeConversionFormats.test_to_datetime_with_NA   s*    $ T&1 *
fh/r2   c                     t        dt        j                  g      }t        ddg      }t	        j
                  ||       y )Nr   r   r   )r   pdNAr   r)   r*   r+   r.   r/   s      r0   %test_to_datetime_with_NA_with_warningz?TestTimeConversionFormats.test_to_datetime_with_NA_with_warning
  s4    h./ ,!67
fh/r2   c                    t        g d      }t        |j                  t              D cg c]  }t        |       c}      }t	        |d|      }t        j                  ||       t        g d      }t        |j                  t              D cg c]  }t        |d d dz   |dd  z          c}      }t	        |d|      }t        j                  ||       y c c}w c c}w )N)    i  z%Yr>   )iA i i    -ri   rO   rS   s         r0   test_to_datetime_format_integerz9TestTimeConversionFormats.test_to_datetime_format_integer  s    '(3@A9Q<@ASU;
vx0-.399S>Ra9QrUS[1QR5%89RSSu=
vx0 A Ss   CCc                     t         j                  d   }d| d}d}t        |||      }t        j                  ||      }||k(  sJ y )Nr   z01-z-2011 00:00:01.978z%d-%b-%Y %H:%M:%S.%fr>   )calendar
month_abbrr   r   strptime)r+   r@   r   valr?   r.   exps          r0   #test_to_datetime_format_microsecondz=TestTimeConversionFormats.test_to_datetime_format_microsecond  sR    ((+
J<12'Su=V,}}r2   zvalue, format, dtz01/10/2010 15:20z%m/%d/%Y %H:%Mz2010-01-10 15:20z01/10/2010 05:43z%m/%d/%Y %I:%Mz2010-01-10 05:43z01/10/2010 13:56:01z%m/%d/%Y %H:%M:%Sz2010-01-10 13:56:01z01/10/2010 08:14 PMz%m/%d/%Y %I:%M %pz2010-01-10 20:14r   )zh_CNit_ITz4fail on a CI build with LC_ALL=zh_CN.utf8/it_IT.utf8F)reasonstrict)marksz01/10/2010 07:40 AMz2010-01-10 07:40z01/10/2010 09:12:56 AMz%m/%d/%Y %I:%M:%S %pz2010-01-10 09:12:56c                 *    t        |||      |k(  sJ y rF   r   )r+   r@   valuer?   dts        r0   test_to_datetime_format_timez6TestTimeConversionFormats.test_to_datetime_format_time'  s    Z 5u=CCCr2   c                     t        g d      }t        |dd|      }t        |j                  j                  dd      d|      }t	        j
                  ||       y )N)19MAY11foobar19MAY11z19MAY11:00:00:00z19MAY11 00:00:00Zz%d%b%yFr?   exactr@   z(\d+\w+\d+))expandr>   )r   r   rQ   extractr)   rR   rs   s        r0   test_to_datetime_with_non_exactz9TestTimeConversionFormats.test_to_datetime_with_non_exactV  sX    
 Q
 SeLGGOON5O9(RW
 	vx0r2   %Y-%m-%dr         %Y-%d-%m%Y-%m-%d %H   z%Y-%d-%m %H%Y-%m-%d %H:%M"   z%Y-%d-%m %H:%M%Y-%m-%d %H:%M:%S8   %Y-%d-%m %H:%M:%S%Y-%m-%d %H:%M:%S.%f@ z%Y-%d-%m %H:%M:%S.%f%Y-%m-%d %H:%M:%S.%f%z	UTC+01:00tzz%Y-%d-%m %H:%M:%S.%f%zc                 .    t        d|d      }||k(  sJ y )Nz 2000-01-03 12:34:56.123456+01:00Fr?   r   r   )r+   r@   r?   r/   r.   s        r0   (test_non_exact_doesnt_parse_whole_stringzBTestTimeConversionFormats.test_non_exact_doesnt_parse_whole_stringd  s%    4 .vU
 !!!r2   rH   )z2012-01-01 09:00:00.000000001z2012-01-01 09:00:00.000001z2012-01-01 09:00:00.001z2012-01-01 09:00:00.001000z2012-01-01 09:00:00.001000000c                 H    t        ||      }t        |d|      }||k(  sJ y )Nr@   r   r>   r   )r+   r@   rH   r/   r.   s        r0   #test_parse_nanoseconds_with_formulaz=TestTimeConversionFormats.test_parse_nanoseconds_with_formula  s-     s%0S)?uM!!!r2   zvalue,fmt,expected)2009324z%Y%W%wz
2009-08-13)2013020z%Y%U%wz
2013-01-13c                 <    t        |||      t        |      k(  sJ y rF   rG   )r+   r   fmtr/   r@   s        r0   test_to_datetime_format_weeksz7TestTimeConversionFormats.test_to_datetime_format_weeks  s      5E:i>QQQQr2   zfmt,dates,expected_datesz%Y-%m-%d %H:%M:%S %Z2010-01-01 12:00:00 UTCr\   2010-01-01 12:00:00UTC%Y-%m-%d %H:%M:%S%zz2010-01-01 12:00:00+0100<   minutestzinfo%Y-%m-%d %H:%M:%S %z2010-01-01 12:00:00 +01002010-01-01 12:00:00 Zc                 `    t        ||      }t        |      }t        j                  ||       y r   )r   r   r)   rA   )r+   r   datesexpected_datesr.   r/   s         r0   )test_to_datetime_parse_tzname_or_tzoffsetzCTestTimeConversionFormats.test_to_datetime_parse_tzname_or_tzoffset  s)    X U3/(
)r2   )r   z2010-01-01 12:00:00 GMTz2010-01-01 12:00:00 US/PacificGMT
US/Pacific2010-01-01 12:00:00 -0100c                     d}t        j                  t        |      5  t        ||       d d d        y # 1 sw Y   y xY w)N6Mixed timezones detected. Pass utc=True in to_datetimer^   r   ra   rb   rc   r   )r+   r   r   r   msgs        r0   ;test_to_datetime_parse_tzname_or_tzoffset_utc_false_removedzUTestTimeConversionFormats.test_to_datetime_parse_tzname_or_tzoffset_utc_false_removed  s8    D G]]:S1 	+c*	+ 	+ 	+   5>c                 v    g d}g d}d}t        ||d      }t        |      }t        j                  ||       y )N)r   r   z2010-01-01 12:00:00 +0300z2010-01-01 12:00:00 +0400)z2010-01-01 11:00:00+00:00z2010-01-01 13:00:00+00:00z2010-01-01 09:00:00+00:00z2010-01-01 08:00:00+00:00r   Tr?   utcr   )r+   r   r   r   r.   r/   s         r0   =test_to_datetime_parse_tzname_or_tzoffset_different_tz_to_utczWTestTimeConversionFormats.test_to_datetime_parse_tzname_or_tzoffset_different_tz_to_utc  s?    

 %U3D9 0
fh/r2   offset)z+0z-1fooUTCbarz:10z
+01:000:01r   c                     d}d|z   }dj                  dt         ddt         dg      }t        j                  t        |      5  t        |g|       d d d        y # 1 sw Y   y xY w)	Nr   z2010-01-01 12:00:00 |z,^time data ".*" doesn\'t match format ".*". $?^unconverted data remains when parsing with format ".*": ".*". r^   r   joinPARSING_ERR_MSGra   rb   rc   r   )r+   r   r   r   r   s        r0   )test_to_datetime_parse_timezone_malformedzCTestTimeConversionFormats.test_to_datetime_parse_timezone_malformed  su     %%.hh??BSSTUR"#1&
 ]]:S1 	,s+	, 	, 	,s   AA'c                     d}t        dgd      }t        ||      }t        dgdd      }t        j                  ||       y )	Nr   r   foo)namer   r   r   )r   r   )r   r   r   r)   r*   )r+   r   rH   r.   r/   s        r0   *test_to_datetime_parse_timezone_keeps_namezDTestTimeConversionFormats.test_to_datetime_parse_timezone_keeps_name  sE    $,-E:S- "7!8UO
fh/r2   ),__name__
__module____qualname__r1   ra   markparametrizer   rD   rI   rV   re   rj   rt   rz   r%   r`   r   r   r   r   r   r   r   r   r   paramxfaillocale	getlocaler   tdskip_if_not_us_localer   r   r   r   r   r   r   r   r   r   r    r2   r0   r    r    J   s#   0 [[ :&	*(=y?TU
 :&	*(=y?TU		
** [[000000	

"
"
1<61	11 [[ +RVV,S)+&x(x%'	
11 [[ RVVZ<:&? ZRVV<:&? 2668X6:&? 8RVVX6:&?#	
21321 [[ eeWnug.eeWdUG$()-.
 <*?@<*?@BFFBEE"D*?@BFFBEE"H.CD	
 0! 001 [[!19=O3PQ!19=O3PQ%#/0 FLL%#,-kk''$F$$&q)-??Q  ( 		 FLL%#,-kk''$F$$&q)-??Q  ( 		 FLL(&/0kk''$F$$&q)-??Q  ( 		=(	
+XDY+XD 1 1 [[4A./4A./IdAq"56IdAq"56yq!R<=yq!R<= )D!QB"CD )D!QB"CD#YtQ2r2v%NO#YtQ2r2v%NO($1b"b&[I
 )$1b"b&[I	
."/." [[	
	"	" [[//	
RR [[" '*+a/0U;<q@ &+,q0-hyQS?T6U
 	 ',-1-hyQS?T6U
 	 '(*AB-hyQR?S6T -hyQR?S6T	5&	
)T*U)T* [[" ' 3>3>3E ',.IJ-hyQS?T6U -hyQT?U6V		
<+=<+0( [[D,,0r2   r    c                      e Zd Zd Zd Zej                  j                  d      d        Zd Z	d Z
ej                  j                  ddd	gd
dg      d        Zej                  j                  dddgddg      ej                  j                  d ej                  dddg eddgd      d       ej                  dddg eddg      j                  d       d!       ej                  dddg eddgd      d"       ej                  dd#dg eddgd      d$      g      ej                  j                  d%ed& g      d'                      Zej                  j                  dddgddg      ej                  j                  d%ed( g      d)               Zej                  j                  d* ej                  d ed+d,-       ed.d/-      egd0       ej                  d ed+d,-       ed1d/-      egd2      g      d3        Zej                  j                  d* ej                  d eg d4d      d5       ej                  d eg d6d      d7      g      d8        Zej                  j                  dddgddg      ej                  j                  d9 ej                  dd:gd;      g      ej                  j                  d%ed< g      d=                      Zd> Zej                  j                  d?d@dA edBdCdDdEdE      gdFdA edGdHdHdEdE      gdIdA edGdHdJdEdE      gdKdA edLdCdMdEdE      gdNdA edLdCdDdEdE      gdOdA edLdCdPdEdE      gdQdA edRdCdSdEdE      gg      dT        Zej                  j                  dUg dVg dWg      dX        Zej                  j                  dUg dYg dZg d[g d\g d]g d^g d_g d`g dag dbg dcg ddg deg dfg dgg dhg dig djg dkg      ej                  j                  dldmdng      do               Zej                  j                  dpdqdrg      ds        Zej<                  ej                  j                  dtddg      ej                  j                  dpdqdrg      du                      Zdv Z dw Z!ej<                  ej                  jE                  e#dxy      dz               Z$ej<                  ej                  jE                  e#dxy      ej                  j                  dpd{d|g      d}                      Z%ej                  j                  d~ddg      d        Z&ej                  j                  d      ej                  jE                  e#dxy      ej                  j                  dg d      ej                  j                  dddg      d                             Z'ej                  j                  d e(jR                  d       e(jR                  d      g      d        Z*ej                  j                  dddg      d        Z+ej                  j                  d e(jR                  d       e(jR                  d      g      ej                  j                  dldmdng      d               Z,d Z-ej                  j                  dddg      d        Z.d Z/d Z0d Z1d Z2ej                  j                  de3efe4efe(jj                  efe6e6fg      d        Z7ej                  j                  dd eddt-      gd eddt-      gg      d        Z8d Z9d Z:ej                  j                  dddg      d        Z;d Z<ej                  j                  d~ddg      d        Z=d Z>ej                  j                  d~e?e@g      d        ZAej                  j                  dldndmg      d        ZBej                  j                  dddg      ej                  j                  ddqdg      d               ZCej                  j                  ddg      ej                  j                  ddqdg      d               ZDej                  j                  ddgdgg dg      ej                  j                  ddqdg      d               ZEej                  j                  dtddqg      ej                  j                  dddqg      ej                  j                  d%e4eFe(jj                  e3eGg      d                      ZHd ZIej                  j                  dtddqg      ej                  j                  dddqg      d               ZJd ZKej                  j                  ddqe(j                  fefeMz  z   efeMdz   z  dfdq ed      j                  d      fefeMz  z   e ed      j                  d      fefeMz  z   dfdefeMz  z   d ed      fz   efeMdHz   z   ed       ed      fz   d ff      dĄ        ZNej                  j                  d e6egdz  dqgdz  z   dǬ       e6egdz  dqgdz  z   dǬ       e6dqgdz         e6dqgdz         e6dgdz         e6dgdz         e6eOj                  gdz         e6eOj                  gdz         e6e(j                  gdz         e6e(j                  gdz        g
      dʄ        ZQej                  j                  dg d̢      d̈́        ZRd΄ ZSej                  j                  dddg      ej                  j                  d eddHdH       eTddHdH       e(jR                  dԫ      ddg      dք               ZUdׄ ZVd؄ ZWdل ZXdڄ ZYdۄ ZZd܄ Z[d݄ Z\ej                  j                  d ed߫       edd-      f edd-       edd-      fg      d        Z]ej                  j                  dg d      d        Z^d Z_d Z`ej                  j                  dddgd edd-      gd edRdHdHd      j                   ebj                  d            gg      d        Zdyq)TestToDatetimec                 F   g d}t        |D cg c]  }t        |      j                  d       c}      }t        |      }t        j                  ||       t        |d      }t        j                  ||       t        |d      }t        j                  ||       y c c}w )N)z2016-01-01 01:02:03z2016-01-01 01:02:03.001z2016-01-01 01:02:03.001002z2016-01-01 01:02:03.001002003nsISO8601r   mixed)r   r   as_unitr)   r*   r   )r+   valsrU   r/   result1result2result3s          r0   #test_to_datetime_mixed_string_resosz2TestToDatetime.test_to_datetime_mixed_string_resos#  s    
 !d!K)A,"6"6t"<!KL%
gx0d95
gx0d73
gx0 "Ls   !Bc                 *    t        d       t        u sJ y Nr   r   r+   s    r0   test_to_datetime_nonez$TestToDatetime.test_to_datetime_none6  s    4 C'''r2   zignore:Could not infer formatc                    d}d}t        j                  t        |      5  t        |       d d d        t        j                  t        |      5  t        |g       d d d        t        |d      }|t        u sJ t        |gd      }t        t        gd      }t        j                  ||       y # 1 sw Y   xY w# 1 sw Y   cxY w)N08335394550z+Parsing "08335394550" to datetime overflowsr^   rv   rp   rr   r"   )ra   rb   r   r   r   r   r)   r*   )r+   rH   r   resr   s        r0   test_to_datetime_overflowz(TestToDatetime.test_to_datetime_overflow:  s    
 ;]].c: 		 ]].c: 		 #h/czz3%1SE)
c3'	 		 	s   B2B>2B;>Cc                 8   t        ddddt        t        d                   }t        ddddt        t        d                   }t        d|g      }t        ||g      j	                  t        t        d	                  }t        j                  ||       y )
N  r      )hoursr      z2020-01-01 17:00 -0100r   r   )r   r   r   r   
tz_convertr)   r*   )r+   d1d2r  r/   s        r0   *test_to_datetime_mixed_datetime_and_stringz9TestToDatetime.test_to_datetime_mixed_datetime_and_stringM  s    dAq"Xyq7I6I-JKdAq"Xyq7I6I-JK3R89Bx(33HYs=S4TU
c8,r2   c                    ddg}t        |D cg c]  }t        |       c}      }t        |d      }t        |d d d   d      d d d   }t        |      }t        |d d d         d d d   }t        j                  ||       t        j                  ||       t        j                  ||       t        j                  ||       y c c}w )Nz
2016-01-01r   r  r   r   r   r   r)   r*   )r+   r  rU   r/   r.   r  r  result4s           r0   )test_to_datetime_mixed_string_and_numericz8TestToDatetime.test_to_datetime_mixed_string_and_numericU  s    a  !=1)A,!=>T'2d4R4j9$B$?%TrT
+DbD1
fh/
gx0
gx0
gx0 ">s   Cr?   r   r   r  non-ISO8601idsc                     t        ddd      }t        d|g|      }t        ddgd      }t        j                  ||       y )	Nr  r   r\   
2020-01-01r   z
2020-01-02r[   r"   )r   r   r   r)   r*   )r+   r?   r$  r  r/   s        r0   &test_to_datetime_mixed_date_and_stringz5TestToDatetime.test_to_datetime_mixed_date_and_stringc  sD    
 $1<,V< ,!=XN
c8,r2   r   %Y-%d-%m %H:%M:%S%zr   znon-ISO8601 formatzISO8601 formatzutc, args, expectedTz2000-01-01 01:00:00-08:00z2000-01-01 02:00:00-08:00z2000-01-01 09:00:00+00:00z2000-01-01 10:00:00+00:00datetime64[us, UTC]r"   zall tz-aware, with utc)idFz2000-01-01 01:00:00+00:002000-01-01 02:00:00+00:00uszall tz-aware, without utcz%all tz-aware, mixed offsets, with utc2000-01-01 01:00:00z+tz-aware string, naive pydatetime, with utcconstructorc                 4    t        |       j                         S r  r   to_pydatetimerU   s    r0   <lambda>zTestToDatetime.<lambda>      il88: r2   c                      ||d         }|d   }t        ||g||      }|t        u r|j                  d      }t        j                  ||       y )Nr   r   r   r6  )r   r   r  r)   r*   )	r+   r   r   argsr/   r8  ts1ts2r.   s	            r0   6test_to_datetime_mixed_datetime_and_string_with_formatzETestToDatetime.test_to_datetime_mixed_datetime_and_string_with_formatm  sV    p $q'"1gc3Z=)#''-H
fh/r2   c                 4    t        |       j                         S r  r:  r<  s    r0   r=  zTestToDatetime.<lambda>  r>  r2   c                     ddg} ||d         }|d   }d}t        j                  t        |      5  t        ||g|d       d d d        y # 1 sw Y   y xY w)	Nr7  r5  r   r   r   r^   Fr   r   )r+   r   r8  r@  rA  rB  r   s          r0   Mtest_to_datetime_mixed_dt_and_str_with_format_mixed_offsets_utc_false_removedz\TestToDatetime.test_to_datetime_mixed_dt_and_str_with_format_mixed_offsets_utc_false_removed  s^    " &'BC$q'"1gF]]:S1 	;c
3E:	; 	; 	;   AAzfmt, expectedz2000-01-01 09:00:00+0100r   r   z2000-01-02 02:00:00+0200z	UTC+02:00zISO8601, non-UTCz2000-02-01 02:00:00+0200znon-ISO8601, non-UTCc                     d}t        j                  t        |      5  t        g d|d       d d d        y # 1 sw Y   y xY w)Nr   r^   z2000-01-01 09:00:00+01:00z2000-01-02 02:00:00+02:00NFr   r   )r+   r   r/   r   s       r0   =test_to_datetime_mixed_offsets_with_none_tz_utc_false_removedzLTestToDatetime.test_to_datetime_mixed_offsets_with_none_tz_utc_false_removed  s>    8 G]]:S1 	P	 	 		   8A)2000-01-01 08:00:00+00:00z2000-01-02 00:00:00+00:00r   zISO8601, UTC)rL  z2000-02-01 00:00:00+00:00r   znon-ISO8601, UTCc                 P    t        g d|d      }t        j                  ||       y )NrI  Tr   r   r)   r*   )r+   r   r/   r.   s       r0   (test_to_datetime_mixed_offsets_with_nonez7TestToDatetime.test_to_datetime_mixed_offsets_with_none  s)    . L

 	fh/r2   r@  z2000-01-01 02:00:00-07:00z*all tz-aware, mixed timezones, without utcc                 4    t        |       j                         S r  r:  r<  s    r0   r=  zTestToDatetime.<lambda>  r>  r2   c                      ||d         } ||d         }t        j                  t        d      5  t        ||g|d       d d d        y # 1 sw Y   y xY w)Nr   r   z1cannot be converted to datetime64 unless utc=Truer^   Fr   r   )r+   r   r@  r8  rA  rB  s         r0   =test_to_datetime_mixed_datetime_and_string_with_format_raiseszLTestToDatetime.test_to_datetime_mixed_datetime_and_string_with_format_raises  sY    0 $q'"$q'"]]Q
 	; c
3E:	; 	; 	;rG  c                 n   t        j                  d      }t        |g      }t        dd      }t	        |      |k(  sJ t	        |j
                  d         |k(  sJ t	        |g      }t        |g      }t        j                  ||       t	        |      }t        |      }t        j                  ||       y )Nz2019-02-04 10:18:46.297000+0000z2019-02-04 10:18:46.297000r   r   r   )
r%   str_r   r   r   ilocr   r)   r*   rR   )r+   r   rT   r   r  r/   s         r0   test_to_datetime_np_strz&TestToDatetime.test_to_datetime_np_str'  s     9:eWo4?5!S(((388A;'3...5'"#<
c8,#(#
sH-r2   zs, _format, dtz2015-1-1z%G-%V-%u  r      r   z2015-1-4  r   z2015-1-7r   z	2024-52-1i     z	2024-52-7z2025-1-1   z	2020-53-1r     c                 (    t        ||      |k(  sJ y r   r   )r+   s_formatr   s       r0   %test_to_datetime_iso_week_year_formatz4TestToDatetime.test_to_datetime_iso_week_year_format;  s     1W-333r2   zmsg, s, _format)z'Week 53 does not exist in ISO year 2024z	2024 53 1%G %V %u)z'Week 53 does not exist in ISO year 2023z	2023 53 1ra  c                 ~    t        j                  t        |      5  t        ||       d d d        y # 1 sw Y   y xY w)Nr^   r   r   )r+   r   r^  r_  s       r0   test_invalid_iso_week_53z'TestToDatetime.test_invalid_iso_week_53K  s1    " ]]:S1 	+'*	+ 	+ 	+s   3<)dISO week directive '%V' is incompatible with the year directive '%Y'. Use the ISO year '%G' instead.1999 50z%Y %V)xISO year directive '%G' must be used with the ISO week directive '%V' and a weekday directive '%A', '%a', '%w', or '%u'.z1999 51z%G %V)rf  z1999 Mondayz%G %A)rf  z1999 Monz%G %a)rf  1999 6z%G %w)rf  rg  z%G %u)rf  2051z%G)`Day of the year directive '%j' is not compatible with ISO year directive '%G'. Use '%Y' instead.z1999 51 6 256z%G %V %u %j)rd  1999 51 Sundayz%Y %V %A)rd  1999 51 Sunz%Y %V %a)rd  	1999 51 1z%Y %V %w)rd  rl  z%Y %V %u)xISO week directive '%V' must be used with the ISO year directive '%G' and a weekday directive '%A', '%a', '%w', or '%u'.20z%V)rm  rj  %V %A)rm  rk  z%V %a)rm  rl  z%V %w)rm  rl  z%V %u)ri  re  z%G %j)rm  z	20 Mondayro  rp   rn   rv   c                     t        j                         dk7  rKt        j                         dk7  r3t        j                  t        |      5  t        |||       d d d        y y y # 1 sw Y   y xY w)N)r   UTF-8)r   rq  r^   r   )r  r  ra   rb   rc   r   )r+   r   r^  r_  rp   s        r0   test_error_iso_week_yearz'TestToDatetime.test_error_iso_week_year_  sk    @ !338H8H8J O
 9
 z5 >Agf=> >	9
3> >s   
A$$A-r   Nz
US/Centralc                 \    t        ddd|      }|j                  }t        |      }||u sJ y )N
1965-04-03   2Wperiodsfreqr   )r   _datar   )r+   r   dtir-   r.   s        r0   test_to_datetime_dtarrz%TestToDatetime.test_to_datetime_dtarr  s3     rDiiS!}}r2   r   c                    t        j                  d      }t        ddd|      } ||      }|j                  t	        j
                  |j                  d|                  }t        ||      }t        ||      j                  t	        j
                  |j                  d|s|nd	                  }|s|t        ur||u sJ |t        u rt        j                  ||       y t        j                  ||       y )
Npyarrowrt  ru  rv  rw  r  )unitr   r   r   )ra   importorskipr   astyper   
ArrowDtype	timestampr   r   r)   rR   r*   )	r+   r   r   rB   par{  	dti_arrowr.   r/   s	            r0   test_to_datetime_arrowz%TestToDatetime.test_to_datetime_arrow  s       +rDc"JJr}}R\\t\-KLM	YC0s,33MM",,DsR,NO
 f4 Y&&&f$""684!!&(3r2   c                 T    t        t        ddd            }|t        ddd      k(  sJ y )N  r      r   r   r+   actuals     r0   test_to_datetime_pydatetimez*TestToDatetime.test_to_datetime_pydatetime  s,    XdAr23$2....r2   c                 >    t        d      }|t        ddd      k(  sJ y )N20080115r  r   r  r  r  s     r0   test_to_datetime_YYYYMMDDz(TestToDatetime.test_to_datetime_YYYYMMDD  s#    Z($2....r2   ztzset is not available on WASMr   c                 x   t        j                  d      5  t        d      }t        d      }t        dg      d   }t	        |j
                  |j
                  z
        dk  sJ t	        |j
                  |j
                  z
        dk  sJ |j                  J |j                  J 	 d d d        y # 1 sw Y   y xY w)N
US/Easternnowr       _B)r)   set_timezoner   r   abs_valuer   )r+   r  pdnowpdnow2s       r0   test_to_datetime_nowz#TestToDatetime.test_to_datetime_now  s     __\* 	)E"C&E %)!,F u||cjj01D888v}}szz12T999<<'''==(((	) 	) 	)s   BB00B9zPacific/AucklandzUS/Samoac                    t        j                  |      5  t        j                  d      j	                  d      j	                  t        j
                        }t        d      }t        dg      d   }t        d      }t        j                         }t        |j                         j                  |z
        dk  sJ t        |j                         j                  |z
        dk  sJ t        |j                  |j                  z
        dk  sJ t        |j                  |j                  z
        dk  sJ |j                  J |j                  J 	 d d d        y # 1 sw Y   y xY w)Ntodaydatetime64[us]r   r  )r)   r  r%   
datetime64r  int64r   r   r  r  	normalizer  r   )r+   r   nptodaypdtodaypdtoday2tstodaytstoday2s          r0   test_to_datetime_todayz%TestToDatetime.test_to_datetime_today"  s/    __R  	+mmG,334DELLRXXVG!'*G"G9-a0H(G (H w((*11G;<tCCCx))+22W<=DDDw~~67$>>>w~~784???>>)))??***!	+ 	+ 	+s   D;EE$rH   r  r  c                     t        |g       y r  r   )r+   rH   s     r0   (test_to_datetime_today_now_unicode_bytesz7TestToDatetime.test_to_datetime_today_now_unicode_bytes>  s    SEr2   z8ignore:Timestamp.utcnow is deprecated:DeprecationWarningzformat, expected_ds))r   
2020-01-03)r2  z
2020-03-01)Nr  zstring, attribute)r  utcnow)r  r  c                     t        d|g|d      }t        | t        t        |             gd      }||z
  j	                         j                         dk  sJ y )Nz2020-01-03 00:00:00ZTr   zdatetime64[s, UTC]r"   r   )r   r   getattrr   maxtotal_seconds)r+   r?   expected_dsstring	attributer.   r/   s          r0    test_to_datetime_now_with_formatz/TestToDatetime.test_to_datetime_now_with_formatB  sb    * 4f=fRVW 7')Y79:BV
 6!&&(6681<<<r2   r   
2000-01-01
2000-01-02c                 :    t        ||      t        |      k(  sJ y )Nr   rG   )r+   r@   r   s      r0   test_to_datetime_dt64sz%TestToDatetime.test_to_datetime_dt64s]  s     2U+y}<<<r2   arg, format)
2001-01-01r   )z
01-01-2001z%d-%m-%Yc                     t        |t        j                  d      g|      }t        ddg      }t	        j
                  ||       y )Nr0  r   r  r   r%   r  r   r)   r*   )r+   rH   r?   r.   r/   s        r0   test_to_datetime_dt64s_and_strz-TestToDatetime.test_to_datetime_dt64s_and_strc  s=     c2==#>?O ,!=>
fh/r2   z
1000-01-01z
5000-01-02c                     t        |||      }t        |t              sJ |j                  dk(  sJ |j                  |k(  sJ t        |      }|j                  dk(  sJ |j                  |k(  sJ y )Nrp   r@   r^  )r   
isinstancer   r  asm8)r+   r@   r   rp   tss        r0   'test_to_datetime_dt64s_out_of_ns_boundsz6TestToDatetime.test_to_datetime_dt64s_out_of_ns_boundsp  sk     F%8"i(((ww#~~ww"}}r]ww#~~ww"}}r2   c                    t        j                  t        j                  t         j                        j                  d      }d}t        j                  t        |      5  t        |       d d d        t        j                  t        |      5  t        |d|       d d d        t        |d|      t        u sJ y # 1 sw Y   RxY w# 1 sw Y   ,xY w)NDz7Out of bounds second timestamp: 25252734927768524-07-27r^   rn   r  rv   )r%   r  iinfor  r  ra   rb   r   r   r   r   )r+   r@   dt64r   s       r0   $test_to_datetime_dt64d_out_of_boundsz3TestToDatetime.test_to_datetime_dt64d_out_of_bounds  s    }}RXXbhh/33S9G]].c: 	dO	]].c: 	;WE:	; 4>#EEE	 		; 	;s   B<C<CCr  r^  r  c                    t        j                  d|      t        j                  d|      gdz  }t        ||      }t        |D cg c]  }t	        |      j
                   c}d      }t        j                  ||       g |t        j                  d      }t        |d	       t        |d
|      }t        t        j                  |d            }t        j                  ||       y c c}w )Nr  r  r[  r   rr   r"   
9999-01-01rn   r  rv   r  )	r%   r  r   r   r   r  r)   r*   r&   )r+   r@   r  dtsr.   rU   r/   dts_with_oobs           r0   test_to_datetime_array_of_dt64sz.TestToDatetime.test_to_datetime_array_of_dt64s  s    
 MM,-MM,-
  S. S!A)A,"3"3!AQ
fh/ ;:bmmL9: 	L1\(%H ,g!FG
fh/ "Bs   C,c                     t        dd      t        dd      g}t        ||      }t        ddgd      }t        j                  ||       y )Nz2013-01-01 13:00:00-0800r   r   z2013-01-02 14:00:00-0800r   2013-01-01 13:00:002013-01-02 14:00:00r   r   r   r)   r*   )r+   r@   r-   r.   r/   s        r0   test_to_datetime_tzz"TestToDatetime.test_to_datetime_tz  sV     0\B0\B
 S. "$9:|
 	fh/r2   c                    t        dd      t        dd      g}d}t        j                  t        |      5  t	        ||       d d d        t	        ||d	
      }t        ddgd      }t        j                  ||       y # 1 sw Y   =xY w)Nr  r   r   r  r  zLTz-aware datetime.datetime cannot be converted to datetime64 unless utc=Truer^   r   rv   )r@   rp   z2013-01-01 13:00:00-08:00r   zdatetime64[us, US/Pacific]r"   )r   ra   rb   rc   r   r   r)   r*   )r+   r@   r-   r   r.   r/   s         r0   test_to_datetime_tz_mixedz(TestToDatetime.test_to_datetime_tz_mixed  s     +=+=

6 	 ]]:S1 	*5)	* Sh? (%08T
 	fh/	* 	*s   BBc                     d}d}|gdz  |gdz  z   }d}t        j                  t        |      5  t        ||       d d d        y # 1 sw Y   y xY w)NMarch 1, 2018 12:00:00+0400March 1, 2018 12:00:00+0500rM   r   r^   r   r   )r+   r@   ts_string_1ts_string_2r-   r   s         r0   *test_to_datetime_different_offsets_removedz9TestToDatetime.test_to_datetime_different_offsets_removed  sX     43ma;-!"33F]]:S1 	*5)	* 	* 	*s   AAc                 f   t        j                  d      }|j                  d      }t        j                  |j                  t        ddddd            |j                  t        ddddd            gt        	      }t        |d
|      }t        ddgdd       }t        j                  ||       y )Npytzr  r   r   r   r   )yearmonthdayhourminute   r"   Tr   r@   rL  2000-06-01 07:00:00+00:00r3  r#   ry  )ra   r  r   r%   r&   localizer   r'   r   r   r)   r*   )r+   r@   r  
us_easternr-   r.   r/   s          r0   test_to_datetime_tz_pytzz'TestToDatetime.test_to_datetime_tz_pytz  s    ""6*]]<0
hh##$aQQqI ##$aQQqI	 

 Sd%8 (*EF'

 	fh/r2   z!init_constructor, end_constructorc                     ddg}t        dd      t        dd      g}t         ||      dd|	      } ||      }t        j                  ||       y )
N20100102 12131420100102 1213152010-01-02 12:13:14r   r   2010-01-02 12:13:15%Y%m%d %H%M%STr?   r   r@   )r   r   r)   rA   )r+   r@   init_constructorend_constructorr   expected_datar.   r/   s           r0   test_to_datetime_utc_truez(TestToDatetime.test_to_datetime_utc_true  s`     "#45+6+6

 T"?E
 #=1
)r2   zscalar, expectedr  r  r  r  c                 0    t        |dd|      }||k(  sJ y )Nr  Tr  r   )r+   r@   scalarr/   r.   s        r0    test_to_datetime_utc_true_scalarz/TestToDatetime.test_to_datetime_utc_true_scalar  s"     VOUS!!!r2   c                     d}t        t        |g      d|      }t        t        |d      g      }t        j                  ||       y )Ng {ѴCTr  r   r   )r   r   r   r)   rR   )r+   r@   r  r.   r/   s        r0   2test_to_datetime_utc_true_with_series_single_valuezATestToDatetime.test_to_datetime_utc_true_with_series_single_value	  s?    VRD\t5A9RE234
vx0r2   c                     d}d}t        |gdz        }t        |d|      }t        t        |d      gdz        }t        j                  ||       y )Nz2013-01-01 00:00:00-01:002013-01-01 01:00:00r   Tr  r   r   r   r   r   r)   rR   )r+   r@   r  expected_tsr   r.   r/   s          r0   4test_to_datetime_utc_true_with_series_tzaware_stringzCTestToDatetime.test_to_datetime_utc_true_with_series_tzaware_string  sS    (+rdQhTt599[U;<q@A
vx0r2   zdate, dtype)r  datetime64[ns])r  zdatetime64[ns, UTC]c                     t        t        dd      gd      }t        t        |g|      d|      }t        j                  ||       y )Nr  r   r   zM8[ns, UTC]r"   Tr  r   r   r   r)   rR   )r+   r@   r   r#   r/   r.   s         r0   1test_to_datetime_utc_true_with_series_datetime_nsz@TestToDatetime.test_to_datetime_utc_true_with_series_datetime_ns  sG     ,78
 VTF%8d%P
vx0r2   c                 ~   t        j                  d      }|j                  dd       }|j                  dd       }t        j                  t        ddddd|	      t        dd
ddd|	      gt              }t        |dd|      }t        ddgdd       }t        j                  ||       t        dg|j                  dd             j                  d      }	t        |	      rJ t        |	d|      }t        j                  ||	       t        |	dd|      }t        dgd      }t        j                  ||       y )Nzpsycopg2.tzi)r   r   ir   r   r   r   r   r  r"   rv   T)rp   r   r@   rL  r  r3  r  z2000-01-01 08:00:00r   r6  r  z2000-01-01 13:00:00)ra   r  FixedOffsetTimezoner%   r&   r   r'   r   r   r)   r*   r  r   )
r+   requestr@   psycopg2_tztz1tz2r-   r.   r/   is
             r0   test_to_datetime_tz_psycopg2z+TestToDatetime.test_to_datetime_tz_psycopg2&  sK   ))-8 --T-E--T-Ehhq!Q#6q!Q#6 
 St5I (*EF'

 	fh/ "#..d.F
 '$- 	
 *!,,, Qxu=
fa(QxTG "7!8@UV
fh/r2   c                     d}t        j                  t        |      5  t        |       d d d        t        |d|      t        u sJ y # 1 sw Y    xY w)Nz2dtype bool cannot be converted to datetime64\[ns\]r^   rv   r  )ra   rb   	TypeErrorr   r   )r+   r@   rH   r   s       r0   test_datetime_boolz!TestToDatetime.test_datetime_boolL  sL     D]]9C0 		3xu=DDD	 	s   A		Ac                    t        |       d}t        j                  t        |      5  t	        dt        j                         g|       d d d        t        j                  t        dt         d      5  t	        ddg|       d d d        t        j                  t	        d	dt        d
gd|      t        t	        d	|      t        t        t	        d	|      g             y # 1 sw Y   xY w# 1 sw Y   kxY w)Nz is not convertible to datetimer^   Fr   z2^time data "True" doesn\'t match format "%Y%m%d". r   20130101Tr   g        rv   r  )typera   rb   r  r   r   r  rc   r   r)   r*   r   r   r+   r@   r   s      r0   test_datetime_bool_arrays_mixedz.TestToDatetime.test_datetime_bool_arrays_mixedT  s    e<=]]9C0 	@ 01?	@]]E"#1&
 	9 T*%8	9 	E3,XUKQe,c3AU8ST	
	@ 	@	9 	9s   "C%7C1%C.1C:c                 ~    d}t        j                  t        |      5  t        |       d d d        y # 1 sw Y   y xY w)Nzis not convertible to datetimer^   )ra   rb   r  r   )r+   rH   r   s      r0   test_datetime_invalid_datatypez-TestToDatetime.test_datetime_invalid_datatypeg  s4     /]]9C0 		 	 	s   3<c                     t        j                  t        d      5  t        dgd|       d d d        y # 1 sw Y   y xY w)Nz*':' is a bad directive in format 'H%:M%:S%r^   z00:00:00zH%:M%:S%r   r   )r+   rp   s     r0   test_invalid_format_raisesz)TestToDatetime.test_invalid_format_raisesn  s?     ]]J
 	H ZG	H 	H 	H   5>r   az00:01:99z%H:%M:%Sc                 
   t        |d|      }|t        u sJ dj                  dt         dddt         ddt         d	g      }t        j                  t        |
      5  t        |d|       d d d        y # 1 sw Y   y xY w)Nrv   rp   r?   r   1^time data "a" doesn\'t match format "%H:%M:%S". r   -^Given date string "a" not likely a datetime$D^unconverted data remains when parsing with format "%H:%M:%S": "9". ^second must be in 0..59: 00:01:99$r^   rn   )r   r   r   r   NOT_99ra   rb   rc   r+   r   r?   r  r   s        r0   test_datetime_invalid_scalarz+TestToDatetime.test_datetime_invalid_scalarv  s     %@czzhhD"#1&@W"#1&+F8;?	
 ]]:S1 	>gf=	> 	> 	>s   !A99Bz3000/12/11 00:00:00c                 b   t        |d|      }|"t        |t              sJ |t        |      k(  sJ |t        u sJ |5d}t	        j
                  t        |      5  t        |d|       d d d        y t        |d|      }t        |t              sJ |t        |      k(  sJ y # 1 sw Y   y xY w)Nrv   r  z*^time data ".*" doesn\'t match format ".*"r^   rn   )r   r  r   r   ra   rb   rc   r   s        r0    test_datetime_outofbounds_scalarz/TestToDatetime.test_datetime_outofbounds_scalar  s     %@>c9---)E****#::?Cz5 BE'&AB B eGFCCc9---)E****B Bs   B%%B.rC   )r  bz99:00:00c           	      <   |t        |      dkD  rt        }nd }t        j                  |dd      5  t	        |d|      }d d d        t        j
                  t        t        gt        |      z               dj                  dd	t         d
dt         d
dt         dg      }t        j                  t        |      5  t        j                  |dd      5  t	        |d|       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)Nr   Could not infer formatFr_   raise_on_extra_warningsrv   r  r   r  r  r   r  r  r  r^   rn   )lenUserWarningr)   assert_produces_warningr   r*   r   r   r   r   r  ra   rb   rc   )r+   rC   r?   warnr  r   s         r0   test_datetime_invalid_indexz*TestToDatetime.test_datetime_invalid_index  s,    >c&kAoDD''0%
 	F fXfEC	F 	c=#V1D#EFhh@D"#1&W"#1&+F8;?	
 ]]:S1 	C++4e C F76BC	C 	C!	F 	F"C C	C 	Cs/   C:DD)D:DD	DDz%Y%m%d %H:%M:%Sc                     d}|gdz  } ||      }t        |||d      }t        |||d      }t        j                  ||       y N20130101 00:00:00順 T)r   r?   r@   FrN  )	r+   r   r?   r8  r   
test_datesr   r.   r/   s	            r0   test_to_datetime_cachez%TestToDatetime.test_to_datetime_cache  sN     #Ve^
:&Ts6FtV5I
fh/r2   c                     t        t        t        d      gdz              }t        t        d      gdz        }t        j                  ||       y )N2010-06-02 09:30:003   )r   r   r   r)   r*   r   s      r0   test_to_datetime_from_dequez*TestToDatetime.test_to_datetime_from_deque  sG    UI.C$D#E#JKL	*? @ABFG
fh/r2   c                     d}|gdz  }t        |      }t        |||d      }t        |||d      }t        j                  ||       y r/  ry   )r+   r   r?   r   r2  r   r.   r/   s           r0   test_to_datetime_cache_seriesz,TestToDatetime.test_to_datetime_cache_series  sN     #Ve^
j!Ts6FtV5I
vx0r2   c                 F    d}t        |d      }t        d      }||k(  sJ y )Nr0  Tr   rG   )r+   r   r.   r/   s       r0   test_to_datetime_cache_scalarz,TestToDatetime.test_to_datetime_cache_scalar  s,    "T.01!!!r2   z&datetimelikes,expected_values,exp_unitr\   z
2012-07-26r  z2012 July 26c                     t        |d      }t        |d      }t        |d| d      }t        j                  ||       y )Nr'   r"   rv   r  zdatetime64[]ry   )r+   datetimelikesexpected_valuesexp_unitrT   result_seriesexpected_seriess          r0   *test_convert_object_to_datetime_with_cachez9TestToDatetime.test_convert_object_to_datetime_with_cache  sM    8 
 $C9 z+
 	}o>r2   input   r'   r   r   c                     t        t        gt        |      z  d      }t        ||      }t	        j
                  ||       y )Nrr   r"   r   )r   r   r)  r   r)   rR   )r+   r@   rD  r/   r.   s        r0   *test_to_datetime_converts_null_like_to_natz9TestToDatetime.test_to_datetime_converts_null_like_to_nat  s7    " 3%#e*,G<U%0
vx0r2   zdate, format))z2017-20z%Y-%W)	20 Sundayz%W %A)20 Sunz%W %a)z2017-21z%Y-%U)rH  z%U %A)rI  z%U %ac                     d}t        j                  t        |      5  t        ||       d d d        y # 1 sw Y   y xY w)Nz,Cannot use '%W' or '%U' without day and yearr^   r   r   )r+   r   r?   r   s       r0   'test_week_without_day_and_calendar_yearz6TestToDatetime.test_week_without_day_and_calendar_year   s6     =]]:S1 	-V,	- 	- 	-r   c                     g d}d}t        j                  t        |      5  t        |d       d d d        y # 1 sw Y   y xY w)N)r  r  20100240r   r^   rv   r  r   r+   
ts_stringsr   s      r0   test_to_datetime_coercez&TestToDatetime.test_to_datetime_coerce2  s>    


 G]]:S1 	5
84	5 	5 	5s	   9Azstring_arg, format)zMarch 1, 2018z	%B %d, %Y)z
2018-03-01r   outofboundsi'  r  zJanuary 1, 9999c                    ||g}t        |d|      }t        |t              rB|j                  d      |j                  d      z  rt	        t        ddd      t        gd	      }nEt        |t
              rt	        t        ddd      |gd	      }nt	        t        ddd      |gd	      }t        j                  ||       y )
Nrv   r  z%BJ  r   r   r[   r"   )	r   r  rQ   
startswithr   r   r   r)   r*   )r+   
string_argr?   rQ  rO  r.   r/   s          r0   test_to_datetime_coerce_oobz*TestToDatetime.test_to_datetime_coerce_oob=  s      !+.
ZHk3'd#k&<&<S&AA %htQ&:C%@QHX.$$1%{38H %$1%{38H 	fh/r2   c                     ddg}t        j                  t        dd      5  t        |d      }d d d        t	        t
        t
        gd	      }t        j                  |       y # 1 sw Y   7xY w)
N200622-12-31111111-24-11r&  Fr'  rv   r  rr   r"   )r)   r+  r*  r   r   r   r*   )r+   rO  r.   r   s       r0   #test_to_datetime_malformed_no_raisez2TestToDatetime.test_to_datetime_malformed_no_raise^  sj     %n5
''7QV
 	> !H=F	>
 S#Jg.
fc*	> 	>s   A%%A.c                     ddg}d}t        j                  t        |      5  t        j                  t
        d      5  t        |d       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)NrY  rZ  z~Parsed string "200622-12-31" gives an invalid tzoffset, which must be between -timedelta\(hours=24\) and timedelta\(hours=24\)r^   r&  rn   r  ra   rb   rc   r)   r+  r*  r   rN  s      r0    test_to_datetime_malformed_raisez/TestToDatetime.test_to_datetime_malformed_raisej  s    $n5
K 	 ]]
 
	 ++#;  "	
	 
	 	
	 
	s"   A)AA)A&	"A))A2c                    d}t        |      }t        |      }||k(  sJ t        t        |      gdz        }t        |gdz        }t        j                  ||       t        |gdz        }t        j                  ||       y )N2015-11-18 15:30:00+05:30r\   )r   r   r   r)   r*   )r+   ts_strr.   r/   s       r0   &test_iso_8601_strings_with_same_offsetz5TestToDatetime.test_iso_8601_strings_with_same_offset}  s    ,V$V$!!! )F"3!4q!89fX\*
fh/x!|,
fh/r2   c                     ddt         g}d}t        j                  t        |      5  t	        |       d d d        y # 1 sw Y   y xY w)Nr`  2015-11-18 16:30:00+06:30r   r^   )r   ra   rb   rc   r   rN  s      r0   4test_iso_8601_strings_with_different_offsets_removedzCTestToDatetime.test_iso_8601_strings_with_different_offsets_removed  s@    13NPST
F]]:S1 	$
#	$ 	$ 	$s	   <Ac           	          ddt         g}t        |d      }t        t        dddd      t        dddd      t         gd	
      }t	        j
                  ||       y )Nr`  rd  Tr  rY     r"  
   r   r   )r   r   r   r   r)   r*   )r+   rO  r.   r/   s       r0   0test_iso_8601_strings_with_different_offsets_utcz?TestToDatetime.test_iso_8601_strings_with_different_offsets_utc  s[    13NPST
ZT2 tRR()D"b"*EsKPU
 	fh/r2   c                    dt        d      ddd ddgt              t        fdt        t	                    D              sJ d}t        j                  t        |	      5  t               d d d        y # 1 sw Y   y xY w)
Nr`   z
1990-01-01z2015-03-14T16:15:14.123-08:00z2019-03-04T21:56:32.620-07:00r  r  c              3   2   K   | ]  }|   |   u   y wr  r  ).0r  rT   r  s     r0   	<genexpr>zZTestToDatetime.test_mixed_offsets_with_native_datetime_utc_false_raises.<locals>.<genexpr>  s     ?3q6T!W$?s   r   r^   )	r   r   allranger)  ra   rb   rc   r   )r+   r   rT   r  s     @@r0   8test_mixed_offsets_with_native_datetime_utc_false_raiseszGTestToDatetime.test_mixed_offsets_with_native_datetime_utc_false_raises  s~     l#++
 Tl?eCI.>????F]]:S1 		 	 	s   &A;;Bc                     t        dgdz        }t        t        ddddt        t	        d            	      gdz        }t        j                  ||       y )
Nr  r\   rT  r   r   r      r   r   )r   r   r   r   r   r)   r*   r   s      r0   #test_non_iso_strings_with_tz_offsetz2TestToDatetime.test_non_iso_strings_with_tz_offset  sT    ;<q@A dAq"Xi6L-MNORSS
 	fh/r2   zts, expectedz
2018-01-01r   r   z2018-01-01 08:00c                 ,    t        |d      }||k(  sJ y )NTr  r   )r+   r  r/   r.   s       r0   test_timestamp_utc_truez&TestToDatetime.test_timestamp_utc_true  s     RT*!!!r2   dt_str)00010101130001013000010199990101c                     t        |d      }t        j                  |d      }t        |      }||k(  sJ |j                  |j                  k(  sJ y )NrN   r   )r   r   r   r   r  )r+   rv  r  dtobjr/   s        r0   *test_to_datetime_with_format_out_of_boundsz9TestToDatetime.test_to_datetime_with_format_out_of_bounds  sN     &2!!&(3U#hxx8==(((r2   c                     t        j                  t        d      gt              }t	        |d      }|j
                  t        j                  u sJ y )Nz2012-06-13T01:39:00Zr"   Tr  )r%   r&   r	   r'   r   r   r   r   )r+   r-   r.   s      r0   test_to_datetime_utcz#TestToDatetime.test_to_datetime_utc  s=    hh456fESd+yyHLL(((r2   c                     ddl m}  |dd      }t        ddd|      t        ddd|      t        ddd	|      g}t        |      }|j                  |k(  sJ y )
Nr   )FixedOffseti\z-07:00r   r   r   r\   r   )-pandas.tests.indexes.datetimes.test_timezonesr  r   r   r   )r+   r  	fixed_offr   r.   s        r0   test_to_datetime_fixed_offsetz,TestToDatetime.test_to_datetime_fixed_offset  sb    Mh/	 T1a	2T1a	2T1a	2

 U#yyI%%%r2   r   z2020-10-26 00:00:00+06:00z2020-10-26 00:00:00+01:00r"  zAustralia/Melbournec                     d}t        j                  t        |      5  t        |d       d d d        y # 1 sw Y   y xY w)Nr   r^   Fr  r   )r+   r   r   s      r0   5test_to_datetime_mixed_offsets_with_utc_false_removedzDTestToDatetime.test_to_datetime_mixed_offsets_with_utc_false_removed  s7     G]]:S1 	)%(	) 	) 	)r   )er   r   r   r  r  ra   r   filterwarningsr  r&  r+  r   r1  r  r   r  r   rC  rF  r   rJ  rO  rR  rV  r   r`  rc  rr  r|  r  skip_if_windowsr  r  r  skipifr   r  r  r  r  r%   r  r  r  r  r  r  r  r  r  r  r   listr&   r   r  r  r  r  r  r	  r  r  boolr   r  r  r!  r#  r-  tupler   r3  r7  r9  r;  r`   r   rC  r   r   rG  rK  rP  r   rW  r[  r^  rb  re  ri  rp  rs  ru  r}  r  r  
astimezonezoneinfoZoneInfor  r  r2   r0   r	  r	  "  sA   1&( [[ ?@( A($-1 [[:z*M0J  -- [[	 56!#34  
 [[FLL,.IJ02MN/ , FLL,.IJ02MN'$-. FLL,.IJ02MN/ ; FLL&(CD02MN/ A7$	
'P [[	:;0	Q'b0 [[	 56!#34  
 [[	:;;	;  [[FLL%8[I8[I
 & FLL%8[I8[I
 *	
./. [[FLL%U/ " FLL%U/ &	
*0+*0 [[	 56!#34  
 [[FLL,.IJ?	
 [[	:;;	$;.( [[XdBAq%ABXdAq!Q%?@XdAq!Q%?@*htRQ&BC*htRQ&BCXdBAq%AB*htRQ&BC	
44 [[
	
++
 [[[s	
vn [[X':;> <ovp> [[TD,#78 9 [[UT5M2[[TD,#784 9 3 4*// [[%EF) G )  [[%EF[[T$6
#CD+ E G +2 [[UUG$45 6 [[B [[%EF[[	
 [[	
= G&= [[}r}}\*MBMM,,GH== [[&&	
00 [[}r}}\*MBMM,,GH [[X':;	 <		F [[Vc3Z00 10000(	*0. [[+M"=!XX}%V		
** [[	*?E JK	*?E JK	
""
11 [[5:	
11$0L [[UT5M2E 3E
& [[UT;$78 9 [[X'':;H <H [[WsJ&78[[Xj'9:> ; 9>$ [[W'<&=>[[Xj'9:+ ; ?+$ [[	se
|/EG [[X'=>C ?C> [[UT4L1[[X(94'@A[[]T5"((E5,QR0 S B 200 [[UT4L1[[X(94'@A1 B 21" [[0 rvv#*:!::*Q./ y.66s;<&++,i-55c:;sfGW>WW	 &++,!9\#:;< *Q./\*Il,CDE	
0?10? [[C52:+8<C52:+8<D6B;D6B;B4"9B4"9BEE7R< BEE7R< BFF8b=!BFF8b=!	
11 [[	

-
-	5 [[	')CD [[T1a q!BMM,'	
	0		0&
+&0$0&0 [[|$i&GH,<8,7	
	"	"
 [[X'WX) Y))& [[(*EF()L\*RS+q!R(33%H%%&;<		
))r2   r	  c            	          e Zd Zej                  j                  dddg      ej                  j                  dd ed      g      d               Zej                  j                  dddg      d        Zd Z	d	 Z
d
 Zd Zej                  j                  dddg      d        Zej                  j                  dddg      ej                  j                  dddg      d               Zej                  j                  dg dg degg dg ddgg      d        Zej                  j                  d ed      ddgdd ed      gg      d         Zd! Zej                  j                  deeg      d"        Zej                  j                  d#eej0                  g      d$        Zd% Zd& Zej                  j                  d'd(d)g      d*        Zej                  j                  d'd(d)g      d+        Zd, Zy)-TestToDatetimeUnitr  YMitem   c                 P   t        ||      }d}t        |g|      }t        |g||      }t        j                  ||       t        t        j                  |gt              ||      }t        j                  ||       t        t        j                  |g      ||      }t        j                  ||       t        t        j                  |t
        j                  g      ||      }|j                         d   sJ t        j                  |d d |j                  d             y )Nr  rr   r"   r  r@   r   )r   r   r   r)   r*   r%   r&   r'   r`   r   r  )	r+   r@   r  r  r  r  r#   r/   r.   s	            r0   'test_to_datetime_month_or_year_unit_intz:TestToDatetimeUnit.test_to_datetime_month_or_year_unit_int  s     t$' "U3dV$e<
fh/RXXtfF;$eT
fh/RXXtf-DF
fh/ RXXtRVVn5DN{{}Q
fRaj(//'*BCr2   c                    d| d}t        j                  t        |      5  t        dg|d       d d d        t        j                  t        |      5  t        t	        j
                  dg      |d       d d d        d}t        j                  t        |      5  t        dg|d       d d d        t        dg|d	      }t        t        gd
      }t        j                  ||       t        dg|d	      }t        t        g      }t        j                  ||       t        dg|      }t        dg|      j                  d      }t        j                  ||       y # 1 sw Y   3xY w# 1 sw Y   xY w# 1 sw Y   xY w)Nz(Conversion of non-round float with unit=z is ambiguousr^         ?rn   r  rp   z/Given date string \"1.5\" not likely a datetimez1.5rv   M8[ns]r"         ?r  r   r^  )ra   rb   rc   r   r%   r&   r   r   r)   r*   r  )r+   r@   r  r   r  r/   s         r0   3test_to_datetime_month_or_year_unit_non_round_floatzFTestToDatetimeUnit.test_to_datetime_month_or_year_unit_non_round_float
  sP   
 9mL]]:S1 	:D9	:]]:S1 	D#d7C	D A]]:S1 	<d7;	< 3%d8<#h/
c8, 5'X>u%
c8, 3%d+s.66s;
c8,/	: 	:	D 	D	< 	<s#   E##E0E<#E-0E9<Fc                     d}t        j                  t        |      5  t        dgdd|       d d d        y # 1 sw Y   y xY w)Nz#cannot specify both format and unitr^   r   r  rN   )r  r?   r@   r   r  s      r0   	test_unitzTestToDatetimeUnit.test_unit)  s@     4]]:S1 	E#heD	E 	E 	ErK  c                 .   dddt         t        t        j                  ddg}t	        |dd|      }t        g d	d
      }t        j                  ||       d}t        j                  t        |      5  t	        |dd|       d d d        y # 1 sw Y   y xY w)Nl   qMe;r   r  r   r   r  rv   r  rp   r@   )r   
1970-01-02r  r   r   r   r   r   rr   r"   z8cannot convert input 11111111111111111 with the unit 'D'r^   rn   r   r   r%   r`   r   r   r)   r*   ra   rb   r   r+   r@   rC   r.   r/   r   s         r0   test_unit_array_mixed_nansz-TestToDatetimeUnit.test_unit_array_mixed_nans0  s    #QT3rJV#heL R
 	fh/H]].c: 	GSF	G 	G 	Gs   2BBc                 (   dt         t        t        j                  dg}t	        |dd|      }t        g dd      }t        j                  ||       d	}t        j                  t        |
      5  t	        |dd|       d d d        y # 1 sw Y   y xY w)Nl     #0U.KK% r   rv   r^  rp   r  r@   )r   r   r   r   r   rr   r"   z@cannot convert input 1420043460000000000000000 with the unit 's'r^   rn   r  r  s         r0   $test_unit_array_mixed_nans_large_intz7TestToDatetimeUnit.test_unit_array_mixed_nans_large_int>  s~    +T3FVH3eL !DGT
fh/P]].c: 	GwSF	G 	G 	Gs   /BBc                     d}t        j                  t        |      5  t        ddd|       d d d        y # 1 sw Y   y xY w)Nz4Unknown datetime string format, unable to parse: foor^   r   rn   r^  r  r   r  s      r0   8test_to_datetime_invalid_str_not_out_of_bounds_valuerrorzKTestToDatetimeUnit.test_to_datetime_invalid_str_not_out_of_bounds_valuerrorI  s?     E]]:S1 	FgCuE	F 	F 	F	   7A errorrn   rv   c                 j    t        d      }t        dd||      }||k(  sJ t        |t               sJ y )Nz1970-05-09 14:25:11iǊ r^  r  )r   r   r  )r+   r@   r  r/   r.   s        r0   test_unit_consistencyz(TestToDatetimeUnit.test_unit_consistencyP  s=     23XCUK!!!&),,,r2   rp   r#   float64r  c                     t        ddgd      }t        j                  ddg      j                  |      }t	        |||      }t        j                  ||       y )N2015-06-19 05:33:202015-05-27 22:33:20r  r"   @CA5Cr  )r   r%   r&   r  r   r)   r*   )r+   r@   rp   r#   r/   r-   r.   s          r0   test_unit_with_numericz)TestToDatetimeUnit.test_unit_with_numericX  sW    
 !"$9:(
 hh[1299%@Su=
fh/r2   zexp, arr, warning)r   r  r  )r   r  r  )r  r  r   r   )r  r  r   r   Nc                     t        |d      }t        j                  |d      5  t        |d|      }d d d        t        j                  |       y # 1 sw Y    xY w)Nr  r"   r&  r^   rv   r  )r   r)   r+  r   r*   )r+   r@   r   r-   warningr/   r.   s          r0   test_unit_with_numeric_coercez0TestToDatetimeUnit.test_unit_with_numeric_coerced  sX    $ !H5''7OP 	D XUCF	D
fh/	D 	Ds   AAr-   r  r  r  c                 (   t        |D cg c]  }t        |       c}d      }t        |d|      }t        j                  ||       t        |d|      }t        j                  ||       t        |      }t        j                  ||       y c c}w )Nr  r"   rv   r  rn   )r   r   r   r)   r*   r   )r+   r@   r-   rU   r/   r.   s         r0   test_unit_mixedz"TestToDatetimeUnit.test_unit_mixed{  s|     41)A,4HES?
fh/ S>
fh/s#
fh/ 5s   Bc                 p    d}t        |d|      }t        d      }||k(  sJ t        |d      }||k(  sJ y )Ng aAr^  r  z2015-06-19 19:55:31.877000093r  rG   )r+   r@   r   r.   r/   alts         r0   test_unit_roundingz%TestToDatetimeUnit.test_unit_rounding  sH     #UE:<=!!!C(f}}r2   c           	      J   d}t        t        d      D cg c]  }||z   	 c}      j                  |      }t        |d      }d}t        t        d      D cg c]  }t	        d      t        |      z    c}d| d	      }t        j                  ||       y c c}w c c}w 
NQrE  r^  r  2013-06-09 02:42:28secondsM8[r=  r"   )r   ro  r  r   r   r   r)   rR   )r+   r#   epochtrT   r.   r  r/   s           r0   test_to_datetime_unitz(TestToDatetimeUnit.test_to_datetime_unit  s    r3Aeai34;;EBSs+ r /09Q3GG vQ-
 	vx0 4s   BB nullc           	      D   d}t        t        d      D cg c]  }||z   	 c}|gz         }t        |d      }d}t        t        d      D cg c]  }t        d      t	        |      z    c}t
        gz   d| d	      }t        j                  ||       y c c}w c c}w r  )r   ro  r   r   r   r   r)   rR   )r+   r  r  r  rT   r.   r  r/   s           r0    test_to_datetime_unit_with_nullsz3TestToDatetimeUnit.test_to_datetime_unit_with_nulls  s    r3Aeai3tf<=Ss+ NSTViXY,-	!0DDXevQ-

 	vx0 4 Ys   BBc           	         d}t        t        j                  ddd      D cg c]  }||z   	 c}t        gz         j	                  t
              }t        |d      }t        t        j                  ddd      D cg c]  }t        d      t        |      z    c}t        gz   d	
      }|j                  j                  d      }t        j                  ||       y c c}w c c}w )Nr  r   r\   g      ?r^  r  r  r  r  r"   ms)r   r%   aranger   r  rX   r   r   r   r   r   roundr)   rR   )r+   r  r  rT   r.   r/   s         r0   (test_to_datetime_unit_fractional_secondsz;TestToDatetimeUnit.test_to_datetime_unit_fractional_seconds  s    1a)>?Aeai?4&HIPPQVWSs+ 1a. /09Q3GG e	
 
 &
vx0 @s   C:C!c                     t        dddt        t        j                  gd      }t	        t        d      t        d      gdgdz  z   d	
      }t        j                  ||       y )Nr   r\   r   r  r  r  
1970-01-03r   rr   r"   )r   r   r%   r`   r   r   r)   r*   r   s      r0   test_to_datetime_unit_na_valuesz2TestToDatetimeUnit.test_to_datetime_unit_na_values  sY    aE37cB |$i&=>%1L
 	fh/r2   bad_valr   l   q$8 c                     |dk(  rd| }nd}t        j                  t        |      5  t        dd|gd       d d d        y # 1 sw Y   y xY w)	Nr   z1Unknown datetime string format, unable to parse: z6cannot convert input 111111111111111 with the unit 'D'r^   r   r\   r  r  r   )r+   r  r   s      r0   test_to_datetime_unit_invalidz0TestToDatetimeUnit.test_to_datetime_unit_invalid  sN    eEgYOCJC]]:S1 	3Awc2	3 	3 	3s   AAc                     t        t        d      t        d      gdgdz  z   d      }t        dd|gdd	
      }t        j                  ||       y )Nr  r  r   r   rr   r"   r\   r  rv   r  r)  )r+   r  r/   r.   s       r0   test_to_timestamp_unit_coercez0TestToDatetimeUnit.test_to_timestamp_unit_coerce  sT     !|$i&=>%1L
 aG_3xH
fh/r2   c                    d}d}d|z  }t        d|dz
  | dz   gt              }||z  j                  t        j                        }dD ]  }t        |d|	      }t        j                  |j                  t        j                        j                  t        j                        |j                  t        j                        d
        t        d|dz   gt              }t        d| dz
  gt              }	t        j                  t        |      5  t        |dd	       d d d        t        j                  t        |      5  t        |	dd	       d d d        y # 1 sw Y   <xY w# 1 sw Y   y xY w)Nz"cannot convert input with unit 'D'g  S$Bl            r   g{Gzt?r"   )rn   rv   r  r  g|=)rtolr^   rn   )r   rX   r  r%   r  r   r)   assert_almost_equalr  ra   rb   r   )
r+   r   oneday_in_nstsmax_in_daysshould_succeedr/   
error_moder  should_fail1should_fail2s
             r0   (test_float_to_datetime_raise_near_boundsz;TestToDatetimeUnit.test_float_to_datetime_raise_near_bounds  sP   2),%~'=>e
 #\199"((C- 	J!.s:NG ""rxx(//

;

+		 q-%"78Fq=.5"89G]].c: 	@3w?	@]].c: 	@3w?	@ 	@	@ 	@	@ 	@s   EE)E&)E2)r   r   r   ra   r   r   rX   r  r  r  r  r  r  r  r  r*  r  r   r  r  intr  r   r%   r`   r  r  r  r  r  r  r  r2   r0   r  r    sW   [[Vc3Z0[[Vc5:%67D 8 1D( [[Vc3Z0- 1-<EG	GF [[Ww&9:- ;- [[X':;[[Wy'&:;0 < <0 [[ F1 M8	
00 [[z"K=+y'<=	
00"	 [[WsEl31 41 [[VdBFF^41 511"0 [[Y(@A3 B3 [[Y(@A0 B0@r2   r  c                   <   e Zd Zej                  d        Zd Zd Zej                  j                  dddddd	d
ddddddddg      d        Z
d Zd Zd Zd Zd Zej                  j                  ddgddgg dddgg dg      d        Zd Zd Zd Zd Zd  Zy!)"TestToDatetimeDataFramec                 P    t        ddgddgddgddgd	d
gddgddgddgddgd	      S )NrY    r\   r   r   rM   r     :   ;   rh  rg  r   	r  r  r  r  r  secondr  r6  r  )r   r  s    r0   dfzTestToDatetimeDataFrame.df  sS    tQ1vAr(r(!f!f!f

 	
r2   c                 2   t        |d   |d   |d   d|      }t        t        d      t        d      g      }t        j                  ||       t        |g d   j                         |      }t        dd	g      |_        t        j                  ||       y )
Nr  r  r  r  r  r  r   20150204 00:00:00z20160305 00:0:00r   r   )r   r   r   r)   rR   to_dictr   indexr+   r  r@   r.   r/   s        r0   test_dataframez&TestToDatetimeDataFrame.test_dataframe  s    Z"W+biHPU
 *+Y7I-JK
 	vx0 R 89AAC5Q1v
vx0r2   c                     |g d   j                         }d|d<   t        ||      }t        t        d      t        d      gt	        ddg      	      }t        j                  ||       y )
Nr  r\   r  r   r  z20160205 00:0:00r   r   r  )r  r   r   r   r   r)   rR   )r+   r  r@   df2r.   	expected2s         r0   &test_dataframe_dict_with_constructablez>TestToDatetimeDataFrame.test_dataframe_dict_with_constructable#  sf    )*224GS.*+Y7I-JKA-
	 	vy1r2   r  yearsmonthsdaysr!  r   r  )r  r  r  r  r  r  r  r  r  r  r  r  c                     t        |t        |j                                  j                  |      |      }t	        t        d      t        d      gd      }t        j                  ||       y )Ncolumnsr   z20150204 06:58:10z20160305 07:59:11r[   r"   )r   r  keysrenamer   r   r)   rR   )r+   r  r@   r  r.   r/   s         r0   *test_dataframe_field_aliases_column_subsetzBTestToDatetimeDataFrame.test_dataframe_field_aliases_column_subset.  sa    . RTYY[ 1299$9GuU*+Y7J-KL
 	vx0r2   c           
          ddddddddd	d
	}t        |j                  |      |      }t        t        d      t        d      g      }t	        j
                  ||       y )Nr  r  r  r  r  r  r  r6  r  r  r  r   20150204 06:58:10.00100200320160305 07:59:11.001002003)r   r  r   r   r)   rR   )r+   r  r@   dr.   r/   s         r0   test_dataframe_field_aliasesz4TestToDatetimeDataFrame.test_dataframe_field_aliasesL  sp    

 RYYqY1?7878
 	vx0r2   c                     t        |j                  t              |      }t        t	        d      t	        d      g      }t        j                  ||       y Nr   r  r  )r   r  rQ   r   r   r)   rR   r  s        r0   test_dataframe_str_dtypez0TestToDatetimeDataFrame.test_dataframe_str_dtypeb  sI    RYYs^597878
 	vx0r2   c                     t        |j                  t        j                        |      }t	        t        d      t        d      g      }t        j                  ||       y r
  )r   r  r%   float32r   r   r)   rR   r  s        r0   test_dataframe_float32_dtypez4TestToDatetimeDataFrame.test_dataframe_float32_dtypem  sP     RYYrzz2%@7878
 	vx0r2   c                 (   t        ddgddgddgd      }d}t        j                  t        |	      5  t	        ||
       d d d        t	        |d|      }t        t        d      t        g      }t        j                  ||       y # 1 sw Y   HxY w)NrY  r  r\   rE  r   rM   r  zO^cannot assemble the datetimes: time data ".+" doesn\'t match format "%Y%m%d"\.r^   r   rv   r  r  )
r   ra   rb   rc   r   r   r   r   r)   rR   )r+   r@   r  r   r.   r/   s         r0   test_dataframe_coercez-TestToDatetimeDataFrame.test_dataframe_coercey  s    $BAOP' 	 ]]:S1 	*5)	* S?9%893?@
vx0	* 	*s   BBc                     d}|j                         }d|d<   t        j                  t        |      5  t	        ||       d d d        y # 1 sw Y   y xY w)Nz?extra keys have been passed to the datetime assemblage: \[foo\]r   r   r^   r   )copyra   rb   rc   r   )r+   r  r@   r   r  s        r0    test_dataframe_extra_keys_raisesz8TestToDatetimeDataFrame.test_dataframe_extra_keys_raises  sH    PggiE
]]:S1 	*5)	* 	* 	*   A

Acols)r  r  r  )r  r  r  c                     d}t        j                  t        |      5  t        ||   |       d d d        y # 1 sw Y   y xY w)Nz`to assemble mappings requires at least that \[year, month, day\] be specified: \[.+\] is missingr^   r   r   )r+   r  r@   r  r   s        r0   "test_dataframe_missing_keys_raisesz:TestToDatetimeDataFrame.test_dataframe_missing_keys_raises  s?    5 	 ]]:S1 	/4.	/ 	/ 	/rK  c                 z   d}t        ddgddgddgd      }g d	|_        t        j                  t        |
      5  t        ||       d d d        t        ddgddgddgddgd      }g d|_        t        j                  t        |
      5  t        ||       d d d        y # 1 sw Y   \xY w# 1 sw Y   y xY w)Nz#cannot assemble with duplicate keysrY  r  r\   rE  r   rM   r  )r  r  r  r^   r   )r  r  r  r  )r  r  r  r  )r   r   ra   rb   rc   r   )r+   r@   r   r  s       r0   'test_dataframe_duplicate_columns_raisesz?TestToDatetimeDataFrame.test_dataframe_duplicate_columns_raises  s    3$BAOP-]]:S1 	*5)	* D\QGQFQPQFS
 6]]:S1 	*5)	* 	*	* 	*	* 	*s   B%B1%B.1B:c                     t        ddgddgddgd      }t        |j                  d      |	      }t        t	        d
      t	        d      g      }t        j                  ||       y )NrY  r  r\   r   r   rM   r  int16r   r  20160305 00:00:00)r   r   r  r   r   r)   rR   r+   r@   r  r.   r/   s        r0   test_dataframe_int16z,TestToDatetimeDataFrame.test_dataframe_int16  sf    t1vq!fMN RYYw/u=*+Y7J-KL
 	vx0r2   c                    t        ddgddgddgd      }|d   j                  d	      |d<   |d
   j                  d	      |d
<   t        ||      }t        t	        d      t	        d      g      }t        j                  ||       y )NrY  r  r\   r   r   rM   r  r  int8r  r   r  r  )r   r  r   r   r   r)   rR   r  s        r0   test_dataframe_mixedz,TestToDatetimeDataFrame.test_dataframe_mixed  s    t1vq!fMNk((07uI$$V,5	Ru-*+Y7J-KL
 	vx0r2   c                     t        ddgddgddgd      }d}t        j                  t        |      5  t	        ||       d d d        y # 1 sw Y   y xY w)	Nr   r   r  r   r  z\^cannot assemble the datetimes: unconverted data remains when parsing with format ".*": "1".r^   r   )r   ra   rb   rc   r   )r+   r@   r  r   s       r0   test_dataframe_floatz,TestToDatetimeDataFrame.test_dataframe_float  sX    tQxAOP& 	 ]]:S1 	)%(	) 	) 	)r  c                     t        ddgddgddgd      }t        |d	      }t        t        j                  d
dgd            j
                  j                  d      }t        j                  ||       y )NrY  r  r\   r   r   rM   r  Tr  z
2015-02-04z
2016-03-05r  r"   r   )	r   r   r   r%   r&   r   tz_localizer)   rR   )r+   r  r.   r/   s       r0   test_dataframe_utc_truez/TestToDatetimeDataFrame.test_dataframe_utc_true  sl    t1vq!fMNRT*HHlL19IJ

"[[ 	 	vx0r2   N)r   r   r   ra   fixturer  r  r  r   r   r  r  r  r  r  r  r  r  r  r!  r#  r&  r  r2   r0   r  r    s    ^^
 
1	2 [[  !##  ""	
*1+*11,	1
11* [[HW'e%	
	/	/*	1	1)1r2   r  c                      e Zd Zd Zej
                  j                  dddgddgg      d        Zej
                  j                  dg d      ej
                  j                  d	d
dg      d               Zej
                  j                  dg d      d        Z	ej
                  j                  dg d      d        Z
ej
                  j                  dg d      d        Zej
                  j                  dg d      d        Zej
                  j                  dg d      d        Zej
                  j                  dg d      d        Zd Zej
                  j!                  d      d        Zd Zd Zej*                  d        Zd  Zej*                  ej
                  j                  d!d"d#g      d$               Zd% Zd& Zd' Zd( Zd) Zej
                  j                  d* ed+       ed+      g      d,        Z d- Z!d. Z"d/ Z#d0 Z$d1 Z%d2 Z&d3 Z'd4 Z(d5 Z)ej
                  j                  d6g d7      d8        Z*d9 Z+d: Z,d; Z-ej
                  j                  d<e.e/j`                  g      d=        Z1y>)?TestToDatetimeMiscc                     t        j                  dgt              }d}t        j                  t
        |      5  t        |       d d d        y # 1 sw Y   y xY w)Nz2262-04-11 23:47:16.854775808r"   z'^Out of bounds nanosecond timestamp: .*r^   )r%   r&   r'   ra   rb   r   r   )r+   r-   r   s      r0   %test_to_datetime_barely_out_of_boundsz8TestToDatetimeMisc.test_to_datetime_barely_out_of_bounds  sI     hh78G7]].c: 		 	 	s   AAzarg, exp_str2012-01-01 00:00:0020121001z
2012-10-01c                 J    t        |g|      }t        |      }|d   |k(  sJ y )Nr   r   rG   )r+   r@   rH   exp_strr.   r   s         r0   test_to_datetime_iso8601z+TestToDatetimeMisc.test_to_datetime_iso8601  s.     cU%0 ayCr2   zinput, format))2012%Y-%m)z2012-01r   )
2012-01-01r   )2012-01-01 10r   )2012-01-01 10:00r   )2012-01-01 10:00:00r   )z2012-01-01 10:00:00.123r   r   r   r   TFc                     t        j                  t        d| d| d      5  t        |||       d d d        y # 1 sw Y   y xY w)Ntime data \"z\" doesn't match format \"\"r^   r   r   )r+   rD  r?   r   s       r0   test_to_datetime_iso8601_failsz1TestToDatetimeMisc.test_to_datetime_iso8601_fails  sJ    " ]]"5')HPRS
 	; fE:		; 	; 	;s	   ;A)r3  r2  )r4  r   )r5  r   )r6  r   r7  c                     dj                  dt         ddt         dg      }t        j                  t        |      5  t        ||       d d d        y # 1 sw Y   y xY w)Nr   r   r   z+^time data ".*" doesn't match format ".*". r^   r   r   )r+   rD  r?   r   s       r0   $test_to_datetime_iso8601_exact_failsz7TestToDatetimeMisc.test_to_datetime_iso8601_exact_fails
	  si     hhQ"#1&>>OqQ
 ]]
 	. f-		. 	. 	.s   AA)r<  )z2012-01-01 00r   )z2012-01-01 00:00r   )r,  r   c                 H    t        ddd      }t        ||d      }||k(  sJ y )N  r   Fr   r   r   r+   rD  r?   r/   r.   s        r0   "test_to_datetime_iso8601_non_exactz5TestToDatetimeMisc.test_to_datetime_iso8601_non_exact$	  s.     T1a(U6?!!!r2   ))2020-01z%Y/%m)r0  z%Y/%m/%d)2020-01-01 00z%Y/%m/%dT%H)2020-01-01T00z%Y/%m/%d %H)2020-01-01 00:00z%Y/%m/%dT%H:%M)2020-01-01T00:00z%Y/%m/%d %H:%M)2020-01-01 00:00:00z%Y/%m/%dT%H:%M:%S)2020-01-01T00:00:00z%Y/%m/%d %H:%M:%Sc                     t        j                  t        d| d| d      5  t        ||       d d d        y # 1 sw Y   y xY w)Nr9  z\" doesn\'t match format \"r:  r^   r   r   )r+   rD  r?   s      r0   "test_to_datetime_iso8601_separatorz5TestToDatetimeMisc.test_to_datetime_iso8601_separator3	  sH     ]]"5')I&QST
 	. f-		. 	. 	.s	   :A))rD  r2  )r0  r   )rE  r   )rF  %Y-%m-%dT%H)rG  r   )rH  %Y-%m-%dT%H:%M)rI  r   )rJ  %Y-%m-%dT%H:%M:%S)z2020-01-01T00:00:00.000%Y-%m-%dT%H:%M:%S.%f)z2020-01-01T00:00:00.000000rP  )z2020-01-01T00:00:00.000000000rP  c                 F    t        ddd      }t        ||      }||k(  sJ y Nr  r   r   rA  rB  s        r0   test_to_datetime_iso8601_validz1TestToDatetimeMisc.test_to_datetime_iso8601_validH	  ,    $ T1a(U62!!!r2   ))z2020-1r2  )z2020-1-1r   )z
2020-1-1 0r   )z
2020-1-1T0rM  )z2020-1-1 0:0r   )z2020-1-1T0:0rN  )z2020-1-1 0:0:0r   )z2020-1-1T0:0:0rO  )z2020-1-1T0:0:0.000rP  )z2020-1-1T0:0:0.000000rP  )z2020-1-1T0:0:0.000000000rP  c                 F    t        ddd      }t        ||      }||k(  sJ y rR  rA  rB  s        r0   #test_to_datetime_iso8601_non_paddedz6TestToDatetimeMisc.test_to_datetime_iso8601_non_padded^	  rT  r2   ))z#2020-01-01T00:00:00.000000000+00:00z%Y-%m-%dT%H:%M:%S.%f%z)z2020-01-01T00:00:00+00:00%Y-%m-%dT%H:%M:%S%z)z2020-01-01T00:00:00ZrW  c                 f    t        dddt        j                        }t        ||      }||k(  sJ y )Nr  r   r   r   )r   r   r   r   rB  s        r0   ,test_to_datetime_iso8601_with_timezone_validz?TestToDatetimeMisc.test_to_datetime_iso8601_with_timezone_validt	  s2     T1a=U62!!!r2   c                 F    t        d|      }t        ddd      }||k(  sJ y )N2001r   r   r   r  )r+   r@   rsxps       r0   test_to_datetime_defaultz+TestToDatetimeMisc.test_to_datetime_default	  s'    u-dAq!Rxxr2   z1fails to enforce dayfirst=True, which would raiser  c                     d}t        j                  t        |      5  t        j                  t
        d      5  t        dd|       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)NzInvalid date specifiedr^   zProvide formatz
01-13-2012Tdayfirstr@   r]  r  s      r0   "test_to_datetime_respects_dayfirstz5TestToDatetimeMisc.test_to_datetime_respects_dayfirst	  sn    
 ']]:S1 	F ++K?OP FL4uEF	F 	FF F	F 	Fs"   A&A	A&A#	A&&A/c                 d    t        t        dd            }t        ||      }|d   |d   k(  sJ y )Nr;   rh  rx  r   r   )r   r   r   )r+   r@   rT   r.   s       r0   %test_to_datetime_on_datetime64_seriesz8TestToDatetimeMisc.test_to_datetime_on_datetime64_series	  s5    Z
B78S.ayCF"""r2   c                 F   t        g d      }dt         d}t        j                  t        |      5  t        |d|       d d d        t        |d|      }t        t        dd	d
      t        dd	d
      t        g      }t        j                  ||       y # 1 sw Y   VxY w)N)z
10/18/2006z
10/18/2008 z1^time data " " doesn\'t match format "%m/%d/%Y". r   r^   rn   r  rv   i  rh  r"  r  )
r   r   ra   rb   rc   r   r   r   r)   rR   )r+   r@   rT   r   result_coerceexpected_coerces         r0   %test_to_datetime_with_space_in_seriesz8TestToDatetimeMisc.test_to_datetime_with_space_in_series	  s    67@_DUUVW 	 ]]:S1 	:G59	:#CF (4R"8(4R:PRU!VW
}o>		: 	:s   BB c                     t        g dg d      }t        |d|      } |j                  t        d|      }t        j                  ||       y )N)May 04Jun 02zDec 11r   r\   r   r  %b %yr>   r   r   rP   r)   rR   )r+   r@   r  r/   r.   s        r0   test_to_datetime_with_applyz.TestToDatetimeMisc.test_to_datetime_with_apply	  sC    
 2)Dr'?+gUC
vx0r2   c                 d    t        dd      }t        ddd      j                  d      }||k(  sJ y )Nz2020-01-01 00:00:00UTCz%Y-%m-%d %H:%M:%S%Zr   r  r   r   )r   r   r%  r   s      r0   test_to_datetime_timezone_namez1TestToDatetimeMisc.test_to_datetime_timezone_name	  s7    5>STT1a(44U;!!!r2   rp   rn   rv   c                     t        g dg d      }t        |d|      } |j                  fd      }t        j                  ||       y )N)rl  rm  r   rn  r  ro  ro   c                 "    t        | dd      S )Nro  rv   ro   r   )rU   r@   s    r0   r=  zOTestToDatetimeMisc.test_to_datetime_with_apply_with_empty_str.<locals>.<lambda>	  s    k!GHER r2   rp  )r+   r@   rp   r  r/   r.   s    `    r0   *test_to_datetime_with_apply_with_empty_strz=TestToDatetimeMisc.test_to_datetime_with_apply_with_empty_str	  sG     ,I>r'&NR
 	vx0r2   c                 2    t        d|      }|t        u sJ y Nr   r   r  r+   r@   r.   s      r0   test_to_datetime_empty_sttz-TestToDatetimeMisc.test_to_datetime_empty_stt	  s    Ru-}}r2   c                 X    t        ddg|      }t        |      j                         sJ y rx  )r   r   rn  ry  s      r0   test_to_datetime_empty_str_listz2TestToDatetimeMisc.test_to_datetime_empty_str_list	  s(    b"XU3F|!!!r2   c                 B    t        d      }t        d|      }||k(  sJ y )Nr   r   rA  )r+   r@   r.   r/   s       r0   test_to_datetime_zeroz(TestToDatetimeMisc.test_to_datetime_zero	  s%    1q.!!!r2   c                 N    t        dg|      d   }t        d|      }||k(  sJ y )Nr1  r   r   r   )r+   r@   r/   r.   s       r0   test_to_datetime_stringsz+TestToDatetimeMisc.test_to_datetime_strings	  s/    xu5a8V51!!!r2   c                     g d}|D cg c]  }t        ||       }}|D cg c]  }t        |       }}t        j                  ||       y c c}w c c}w )N)r1  20120101z20120101 12:01:01r   )r   r   r)   r  )r+   r@   r&   rv  r/   date_strr.   s          r0   "test_to_datetime_strings_variationz5TestToDatetimeMisc.test_to_datetime_strings_variation	  sR    9CHIKe4II6;<()H%<<
vx0 J<s
   AAr.   r1  c                 ,    t        ddd      }||k(  sJ y )Nr@  r   )r   r   s      r0   'test_to_datetime_strings_vs_constructorz:TestToDatetimeMisc.test_to_datetime_strings_vs_constructor	  s    T1a(!!!r2   c                     d}t        j                  t        |      5  t        ddgd|       d d d        y # 1 sw Y   y xY w)Nz-^Given date string "1" not likely a datetime$r^   r   1rn   r  r   r  s      r0   $test_to_datetime_unprocessable_inputz7TestToDatetimeMisc.test_to_datetime_unprocessable_input	  s<     >]]:S1 	?C>	? 	? 	?rK  c                     t        j                  d      j                  d      }|j                  d      }t	        |g      }|d   |j                  d      k(  sJ t        |      }||k(  sJ y )Nl    `SD& r[   Or   )r%   r  viewr  r   r   )r+   r  as_objr  r   s        r0   'test_to_datetime_other_datetime64_unitsz:TestToDatetimeMisc.test_to_datetime_other_datetime64_units	  sg    *+00:s#vh'Qx6==----&!r2   c                     t        ddd      }t        |j                        }t        |j                        }t        |      }t        j                  ||       y )Nr;   rE  r  )rx  r  )r   r   rC   r  asi8r)   r*   )r+   rngintsr.   s       r0   !test_to_datetime_list_of_integersz4TestToDatetimeMisc.test_to_datetime_list_of_integers	  sE    Rd;CJJ'CHH~t$
c6*r2   c                     d}t        j                  t        |      5  t        dddd       d d d        y # 1 sw Y   y xY w)Nz>Cannot cast 139999 days 00:00:00 to unit='ns' without overflowr^   z1/1/1700Br1  r  )startry  rx  r  )ra   rb   r   r   r+   r   s     r0   r  z,TestToDatetimeMisc.test_to_datetime_overflow 
  s@     O]]/s; 	NZc6M	N 	N 	Nr  c                     t        t        j                  gdz  dgz   t        j                        }t	        |dd      }t        t
        gdz  t        d      gz   d      }t        j                  ||       y )	N  g  @昃Ar"   r^  rv   r  z2024-04-04 08:23:53datetime64[s])	r   r%   r`   r  r   r   r   r)   rR   )r+   rT   r.   r/   s       r0   5test_to_datetime_float_with_nans_floating_point_errorzHTestToDatetimeMisc.test_to_datetime_float_with_nans_floating_point_error
  sf    bffX_~5RZZHSs8<EDLI&;<==_
 	vx0r2   c                     t        j                  dgt              }t        j                  t
        d      5  t        |d|       d d d        y # 1 sw Y   y xY w)N87156549591102612381000001219H5r"   Unknown datetime string formatr^   rn   r  )r%   r&   r'   ra   rb   rc   r   )r+   r@   invalids      r0   test_string_invalid_operationz0TestToDatetimeMisc.test_string_invalid_operation
  sH    ((=>fM ]]:-MN 	>u=	> 	> 	>s   AAc                    t        j                  ddt         j                  dgt              }t        j                  dd      }t        |      D ](  \  }}t        |      r
t        ||<   t        |      ||<   * t        j                  |      d   }t        j                  ||       t        ||      }t        |t              sJ t        j                   ||j"                         y )	Nr;   r<   z1/4/2000r"   r   r[   r   r   )r%   r&   r`   r'   empty	enumerater   r   r	   r
   array_to_datetimer)   r  r   r  r   assert_numpy_array_equalrC   )r+   r@   stringsr/   r  r   r.   r  s           r0   test_string_na_nat_conversionz0TestToDatetimeMisc.test_string_na_nat_conversion
  s     ((J
BFFJGvV88AX.( 	)FAsCy"#Cj		) ((1!4
vx0gU3'=111
##FGNN;r2   c                 V   t        j                  dt         j                  gt              }d}t	        j
                  t        |      5  t        |d|       d d d        t	        j
                  t        |      5  t        |d|       d d d        y # 1 sw Y   <xY w# 1 sw Y   y xY w)Nz
1/100/2000r"   r  r^   rn   r  )r%   r&   r`   r'   ra   rb   rc   r   )r+   r@   	malformedr   s       r0   'test_string_na_nat_conversion_malformedz:TestToDatetimeMisc.test_string_na_nat_conversion_malformed*
  s    HHlBFF36B	 0]]:S1 	@	'?	@ ]]:S1 	@	'?	@ 	@	@ 	@	@ 	@s   	B;BBB(c           
         g d}t        dt        j                  dt        j                  dg|d      }t        t        d|      t        j                  t        d|      t        j                  t        d|      g|d      }t        ||      }t        ||      }t        t        j                  dd	
      |      }t        d      D ]J  }|j                  |   }	t        |	      rt        |j                  |<   1t        |	|      |j                  |<   L t        j                  ||d       |j                  dk(  sJ t        j                  ||d       |j                  dk(  sJ y )N)r  r$  cr  er;   r=   z1/5/2000r   r  r   r   rM   r[   r"   r  F)check_names)r   r%   r`   r   r  ro  rU  r   r   r)   rR   r   )
r+   r@   idxseriesdseriesr.   dresultr/   r  rU   s
             r0   'test_string_na_nat_conversion_with_namez:TestToDatetimeMisc.test_string_na_nat_conversion_with_name5
  s6   'RVVZ@RW
 Je4Je4Je4 

 V51gU3"((1H5SAq 	?AAAAw#&a #.q#>a 	? 	vxUC{{e###
weD||u$$$r2   r  )hmr^  r  r6  r  c                    t        j                  d| d      }t        g d|      }|j                  j	                  |      }|dv rd}t        j                  d| d      }t        |j	                  |            }|j                  |k(  sJ t        j                  t        |      |       t        j                  t        ||      |       y )Nr  r=  )z2000-01-01T00:00z2000-01-02T00:00r   r   )r  r  r^  )r%   r#   r   rC   r  r   r)   r*   )r+   r@   r  r#   baserC   	exp_dtyper/   s           r0   $test_dti_constructor_numpy_timeunitsz7TestToDatetimeMisc.test_dti_constructor_numpy_timeunitsW
  s     3tfA'JRWX##E*:DHHs4&]+	 Y!78~~***
mF3X>
k&>Ir2   c           	         g d}t        t        ddd      t        ddd      t        ddd      g      }t        |d      }t        t        j                  |      d      }t	        |d|	      }t	        t        j                  |      d|	      }t        t        |      d      }t        t        |      d      }	t        j                  ||       t        j                  ||       t        j                  ||       t        j                  ||       t        j                  ||       t        j                  ||	       y )
N)z
10/02/2014z
11/02/2014z
12/02/2014rW  r\   rh  rg  r   Tra  r`  )	r   r   r%   r&   r   r   r   r)   r*   )
r+   r@   r-   r/   idx1idx2idx3idx4idx5idx6s
             r0   test_dayfirstz TestToDatetimeMisc.test_dayfirstl
  s    8 dAr"HT1b$98D!R;PQ
 S40RXXc]T:3U;288C=4uEU3Z$7VC[48
h-
h-
h-
h-
h-
h-r2   c                    d}ddg}t        ddgdd       }t        |d	      }t        j                  ||       t        j                  t
        |
      5  t        |d	      }d d d        t        j                  |       y # 1 sw Y    xY w)NzzParsing dates in .* format when dayfirst=.* was specified. Pass `dayfirst=.*` or specify a format to silence this warning.
31/12/2014z
10/03/2011rq   z
2011-03-10r  r  Tr  r^   F)r   r   r)   r*   r+  r*  )r+   warning_msgr-   r/   res1res2s         r0   "test_dayfirst_warnings_valid_inputz5TestToDatetimeMisc.test_dayfirst_warnings_valid_input
  s    N 	 \* <(0@t

 3.
h- '';G 	4sU3D	4
h-	4 	4s   BBc                     ddg}t        j                  t        dt         d      5  t	        |d       d d d        y # 1 sw Y   y xY w)Nr  z
03/30/2011z:^time data "03/30/2011" doesn\'t match format "%d/%m/%Y". r   r^   Tr  )ra   rb   rc   r   r   )r+   r-   s     r0   $test_dayfirst_warnings_invalid_inputz7TestToDatetimeMisc.test_dayfirst_warnings_invalid_input
  sP     \*]]  /03
 	, d+	, 	, 	,s	   ?Aklassc                     t        dd      j                  d      }|j                  d      } ||      } ||      }t        |d      }t	        j
                  ||       y )Nz
2015-04-05r   rd  r   r   Tr  )r   r  r%  r   r)   rA   )r+   r  r{  r/   objr.   s         r0   test_to_datetime_dta_tzz*TestToDatetimeMisc.test_to_datetime_dta_tz
  sU     q188???5)Cj?Sd+
)r2   N)2r   r   r   r+  ra   r   r   r0  r;  r>  rC  rL  rS  rV  rY  r^  r  rb  re  rj  r  r  rq  rs  rv  rz  r|  r~  r  r  r   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   _from_sequencer  r  r2   r0   r)  r)    s    [["$9:&	
  
 [[		
 [[WtUm4; 5; [[	
	.	.  [[	
"" [[		
.. [[	
 "! " [[	
 "! " [[	
""
 [[QR	F S	F#
? 1 1" [[X':;
1 < 
1
"""1 [[X	&(9;v;N'OP" Q"?	+N1><&	@ %D [[)J	J".&.,," [[W}m6R6R&ST	* U	*r2   r)  c                       e Zd Zej                  j                  dg dej                  ej                  dgddgddgddgddgddgg      d	        Ze	j                  d
        Zy)TestGuessDatetimeFormat	test_list)2011-12-30 00:00:00.000000r  r  r  r   r   random_stringr  r  c                 r    d}t        j                  |t              }t        j                  |      |k(  sJ y )Nr   r"   )r%   r&   r'   tools _guess_datetime_format_for_array)r+   r  expected_format
test_arrays       r0   $test_guess_datetime_format_for_arrayz<TestGuessDatetimeFormat.test_guess_datetime_format_for_array
  s2    " 1XXiv6
55jA_TTTr2   c                     t        j                  t        j                  t        j                  t        j                  t        j                  gd            }|J y )Nr  r"   )r  r  r%   r&   r`   )r+   format_for_string_of_nanss     r0   -test_guess_datetime_format_for_array_all_nanszETestGuessDatetimeFormat.test_guess_datetime_format_for_array_all_nans
  sB    $)$J$JHHbffbffbff-S9%
! )000r2   N)r   r   r   ra   r   r   r%   r`   r  r  r  r  r  r2   r0   r  r  
  s    [[
 VVRVV9:-.01)?;0123	
 U! U
 1 1r2   r  c                   D   e Zd Zej                  j                  dg d      d        Zd Zd Zd Z	d Z
ej                  j                  dg d	      d
        Zej                  j                  dg d      d        Zej                  j                  dddg      d        Zy)TestToDatetimeInferFormattest_format)z%m-%d-%Yz%m/%d/%Y %H:%M:%S.%frP  c                     t        t        ddd            }|j                  fd      }t        ||      }t        ||      }t	        j
                  ||       y )Nr4   2   r  rx  ry  c                 &    | j                        S r  )strftime)rU   r  s    r0   r=  zdTestToDatetimeInferFormat.test_to_datetime_infer_datetime_format_consistent_format.<locals>.<lambda>
  s    ajj.E r2   r>   r   )r   r   rP   r   r)   rR   )r+   r@   r  rT   s_as_dt_stringswith_formatwithout_formats     `    r0   8test_to_datetime_infer_datetime_format_consistent_formatzRTestToDatetimeInferFormat.test_to_datetime_infer_datetime_format_consistent_format
  sS     Z
BSAB))$EF!/+US$_EB 	{N;r2   c                     g d}t        t        j                  |            }dt         d}t	        j
                  t        |      5  t        ||       d d d        y # 1 sw Y   y xY w)N)01/01/2011 00:00:00z01-02-2011 00:00:00z2011-01-03T00:00:00zL^time data "01-02-2011 00:00:00" doesn\'t match format "%m/%d/%Y %H:%M:%S". r   r^   r   )r   r%   r&   r   ra   rb   rc   r   )r+   r@   r   rT   r   s        r0   $test_to_datetime_inconsistent_formatz>TestToDatetimeInferFormat.test_to_datetime_inconsistent_format
  s_    TRXXd^$%%4$5Q8 	 ]]:S1 	*5)	* 	* 	*s   AA(c                     g d}t        t        j                  |            }t        ||      }t        g dd      }t	        j
                  ||       y )N)zJan/01/2011zFeb/01/2011zMar/01/2011r   )
2011-01-01z
2011-02-01z
2011-03-01r  r"   )r   r%   r&   r   r)   rR   )r+   r@   r   rT   r.   r/   s         r0   "test_to_datetime_consistent_formatz<TestToDatetimeInferFormat.test_to_datetime_consistent_format
  sG    <RXXd^$S.6>N
 	vx0r2   c                    t        t        j                  dt        j                  dt        j                  gt                    }t        ||      }t        dt        dt        gd      }t        j                  ||       y )Nr  01/03/2011 00:00:00r"   r   r  
2011-01-03r  	r   r%   r&   r`   r'   r   r   r)   rR   rs   s        r0   !test_to_datetime_series_with_nansz;TestToDatetimeInferFormat.test_to_datetime_series_with_nans
  si    HH&0ErvvN
 S.3c2:J
 	vx0r2   c           	         t        t        j                  t        j                  t        j                  dddgt                    }t        ||      }t        t        t        dddgd	      }t        j                  ||       y )
Nr  z01/02/2011 00:00:00r  r"   r   r  z
2011-01-02r  r  r  rs   s        r0   'test_to_datetime_series_start_with_nanszATestToDatetimeInferFormat.test_to_datetime_series_start_with_nans  st    HHFFFF))) 	
 S.#|\<@HX
 	vx0r2   ztz_name, offset))r   r   )zUTC-3   )zUTC+3iLc                     t        d| g      }t        |      }t        t        |            }t        t	        d      j                  |      g      }t        j                  ||       y )Nz2019-02-02 08:07:13 r   2019-02-02 08:07:13)r   r   r   r   r   r%  r)   rR   )r+   tz_namer   rT   r.   r   r/   s          r0   "test_infer_datetime_format_tz_namez<TestToDatetimeInferFormat.test_infer_datetime_format_tz_name  s`     ,WI678S!i/09%:;GGKLM
vx0r2   z
ts,zero_tz))r  Z)r  r   )2019-02-02 08:07:13.012345r  )r  r   c                     t        ||z   g      }t        |      }|dk(  rt        j                  nd }t        t	        ||      g      }t        j                  ||       y )Nr  r   )r   r   r   r   r   r)   rR   )r+   r  zero_tzrT   r.   r   r/   s          r0   "test_infer_datetime_format_zero_tzz<TestToDatetimeInferFormat.test_infer_datetime_format_zero_tz#  sS     b7l^$S!$^X\\9RB/01
vx0r2   r?   Nr   c                     t        g d      }t        t        d      t        d      t        d      g      }t        |||      }t        j                  ||       y )N)2014-1-1z2014-2-2z2015-3-3z
2014-01-01z
2014-02-02z
2015-03-03r>   r   )r+   r@   r?   rT   r/   r.   s         r0   %test_to_datetime_iso8601_noleading_0sz?TestToDatetimeInferFormat.test_to_datetime_iso8601_noleading_0s4  sV     9:,',','
 Su=
vx0r2   )r   r   r   ra   r   r   r  r  r  r  r  r  r  r  r  r2   r0   r  r  
  s    [[S<<*111( [[51	1 [[	
11 [[Xj'9:1 ;1r2   r  c                   *   e Zd Zej                  j                  dddgddgddgddgg      d        Zd Zej                  j                  d	ddd
e de	 dfddd
e de	 dfddde	 dfddde	 dfddd
e de	 dfddd
e de	 dfg      d        Z
y)TestDaysInMonthr  
2015-02-29Nr   z
2015-02-32z
2015-04-31c                 8    t        t        |d||            sJ y )Nrv   rp   r?   r@   )r   r   )r+   r@   rH   r?   s       r0   test_day_not_in_month_coercez,TestDaysInMonth.test_day_not_in_month_coerceF  s     KHV5QRRRr2   c                     t         rd}nd}t        j                  t        |      5  t	        dd|       d d d        y # 1 sw Y   y xY w)NzBday 29 must be in range 1..28 for month 2 in year 2015: 2015-02-29z)day is out of range for month: 2015-02-29r^   r  rn   r  )r   ra   rb   rc   r   r  s      r0   test_day_not_in_month_raisez+TestDaysInMonth.test_day_not_in_month_raiseR  sB    VC=C]]:S1 	CWEB	C 	C 	Cs	   ?Azarg, format, msg^z. r   z
2015-29-02r   zD^unconverted data remains when parsing with format "%Y-%m-%d": "2". z
2015-32-02z9^time data "2015-32-02" doesn't match format "%Y-%d-%m". z
2015-31-04c                     t        j                  t        |      5  t        |d||       d d d        y # 1 sw Y   y xY w)Nr^   rn   r	  r   )r+   r@   rH   r?   r   s        r0   !test_day_not_in_month_raise_valuez1TestDaysInMonth.test_day_not_in_month_raise_valueZ  s:    N ]]:S1 	IGF%H	I 	I 	Ir  )r   r   r   ra   r   r   r
  r  DAY_IS_OUT_OF_RANGEr   r  r  r2   r0   r  r  C  sG    [[4 :&:&:&		
SSC [[ '(?*;1= '(?*;1= V"#1& L"#1& '(?*;1= '(?*;1=9!	
$JIK$JIr2   r  c                      e Zd Zej                  j                  dg d eddd      fd eddd      fd eddd      fd	 eddd      fd
 eddd      fd eddd      fd eddd      fd eddd      fd eddd      fd eddd      fd eddd      fd eddd      fd eddd      fd eddd      fd eddd      fd eddd      fd eddd      fd eddd      fd eddd      fd eddd      fd eddd      fd eddd      fd  eddd      fd! eddd      fd" ed#d$d      fd% eddd&      fd' eddd&dd(      fd) eddd&d*d+      fd, eddd&dd(      fd- eddd&d*d+      fd. eddd&dd(      fd/ eddd&dd(d0      fd1 eddd&dd(d0      fd2 eddd&d3d(d0      fd4 eddd&d*d+      fd5 ed6d&d7dd8d9      fd: ed6d&d7      fd; ed6d&d7      fd< ed=dd      fd> ed=d?d      fd@ ed=d?d      fdA ed=d?d      fdB ed=d?d      fdC edDdddE      fdF edDdddEdG      fdH edDdddEdGdI      f      dJ        ZdK ZdL Z	ej                  j                  dMdNdOdO edPdd      fdNdQdO edPdd      fdNdOdQ edRddE      fdNdQdQ edRdEd      fdSdOdO edTdEdU      fdSdQdO edTdEdU      fdSdOdQ ed#dEdV      fdSdQdQ ed#dEdV      fdWdQdO ed#dEd      fg	      dX        Z
ej                  j                  dYdZ eddddd(      gd[ edddd&d$      gg      d\        Zej                  j                  d]d^ e ed_`            dafdb e edc`            ddfg      de        Zyf)gTestDatetimeParsingWrapperszdate_str, expectedr  i  r   2Q2005i  r   2Q052005Q105Q12011Q3r  11Q33Q20113Q112000Q4r   rh  00Q44Q20004Q002000q4z2000-Q4z00-Q4z4Q-2000z4Q-0000q42005z2005-11rg  z2005 11z11-2005z11 2005200511r  rM   20051109	   z20051109 10:15r  z20051109 08H   r   z2005-11-09 10:15z2005-11-09 08Hz2005/11/09 10:15z2005/11/09 10:15:32    z2005/11/09 10:15:32 AMz2005/11/09 10:15:32 PM   z2005/11/09 08HzThu Sep 25 10:36:28 2003i     $   r\  zThu Sep 25 2003zSep 25 2003zJanuary 1 2014rW  z2014-06r  z06-2014z2014-6z6-2014z20010101 12r   r   z20010101 1234r   z20010101 123456r   c                 d   d}t        j                  ||      \  }}ddij                  |d      }t        ||      }t        |g|      }	t        t	        j
                  |gt              ||      }
t        |g|      }t        t        |g      |      }t        t        |g      |      }||fD ]	  }||k(  r	J  |	|
|||fD ]<  }t        t        |      g      j                  |      }t        j                  ||       > |s)t        |      }||k(  sJ t        |dd	|
      }||k(  sJ y y )NT)	yearfirst
nanosecondr  r6  r"   )r+  r@   Sr   )ry  rx  r+  )r   parse_datetime_string_with_resogetr   r%   r&   r'   r   r   r   r   r  r)   r*   r   )r+   r  r/   r@   r+  r  reso_attrnameresor  r  r*  result6result8result9r  r   result5result7s                     r0   test_parsersz(TestDatetimeParsingWrappers.test_parsers  sX   p 	!(!H!H	"

 $

#mT
" 	 h)<xjI>HHhZv.)5
  
i@xj 1YGz 2iHW% 	#C(?"?	#Wgw@ 	,C8!4 56>>tDC!!#s+	,
 )Gh&&& Q)TGh&&&	 r2   c                 |    t        t        t        gd      }t        ||g|      }t        j                  ||       y )Nr  r"   r   )r   r   r   r)   r*   )r+   r@   unique_nulls_fixtureunique_nulls_fixture2r/   r.   s         r0   test_na_values_with_cachez5TestDatetimeParsingWrappers.test_na_values_with_cache  s8     #s?;24IJRWX
fh/r2   c                     t        j                  d      \  }}t        d      }t        d      }t	        dg      d   }|t
        u sJ |t
        u sJ |t
        u sJ |t
        u sJ y )Nr   r   )r   r.  r   r   r   r   )r+   r  _r  r  r*  s         r0   test_parsers_natz,TestDatetimeParsingWrappers.test_parsers_nat  sk    <<UC
e$E"(+#~~#~~#~~#~~r2   z'date_str, dayfirst, yearfirst, expectedz10-11-12Fr@  Ti  z20/12/21i  rE     20201012c                     t        |||      }||k(  sJ t        j                  |||      \  }}|s|st        |      }	|	|k(  sJ t	        ||||      }
t        |g||      d   }||k(  sJ |
|k(  sJ ||k(  sJ y )N)ra  r+  )ra  r+  r@   r   )r	   r   r.  r   r   r   )r+   r@   r  ra  r+  r/   dateutil_resultr  r=  r  r  r*  s               r0   test_parsers_dayfirst_yearfirstz;TestDatetimeParsingWrappers.test_parsers_dayfirst_yearfirst  s    z  8yQ(***<<x9


 	)Gh&&&x9E
  
XSTUV("""("""("""r2   zdate_str, exp_defz10:15z9:05c                     t        |      }t        j                  |      \  }}t        |      }t        |g      }t	        |      }t        |g      d   }	||k(  sJ ||k(  sJ ||k(  sJ ||k(  sJ |	|k(  sJ y )Nr   )r	   r   r.  r   r   r   )
r+   r  exp_defexp_nowr  r=  r  r  r*  r5  s
             r0   test_parsers_timestringz3TestDatetimeParsingWrappers.test_parsers_timestringE  s     /<<XF
h'xj)H%
+A. '!!!'!!!'!!!'!!!'!!!r2   zdt_string, tz, dt_string_reprz2013-01-01 05:45+0545iY  r   z5Timestamp('2013-01-01 05:45:00+0545', tz='UTC+05:45')z2013-01-01 05:30+0530iJ  z5Timestamp('2013-01-01 05:30:00+0530', tz='UTC+05:30')c                     t        d|      }|j                  d      j                  |      }t        ||      }||k(  sJ |t        |      k(  sJ y )Nz2013-01-01 00:00:00r   r   )r   r%  r#  repr)r+   r@   	dt_stringr   dt_string_reprr  dt_times          r0   .test_parsers_timezone_minute_offsets_roundtripzJTestDatetimeParsingWrappers.test_parsers_timezone_minute_offsets_roundtrip[  sV    & 0>&11"5iu5wg...r2   N)r   r   r   ra   r   r   r   r7  r;  r>  rC  rG  r   r   rM  r  r2   r0   r  r    s}   [[1	
8D!Q/01	
xa+,1	
 XdAq)*1	
 xa+,	1	

 XdAq)*1	
 xa+,1	
 XdAq)*1	
 xa+,1	
 XdAq)*1	
 xb!,-1	
 XdB*+1	
 xb!,-1	
 XdB*+1	
 xb!,-1	
  r1-.!1	
" htR+,#1	
$ r1-.%1	
& htR+,'1	
( XdB*+)1	
* XdAq)*+1	
, r1-.-1	
. r1-./1	
0 r1-.11	
2 r1-.31	
4 xa,-51	
6 $A./71	
8 xb!R<=91	
: XdB1a89;1	
<  $Ar2!>?=1	
> xb!Q:;?1	
@  $Ar2!>?A1	
B #HT2q"b"$EFC1	
D &xb!RR'HIE1	
F &xb!RR'HIG1	
H xb!Q:;I1	
J ($2r2r)JKK1	
L q" 56M1	
N HT1b12O1	
P xa34Q1	
T q!,-U1	
V q!,-W1	
X xa+,Y1	
Z xa+,[1	
\ HT1a45]1	
^ htQ2r:;_1	
` q!RR @Aa1	
4j"'k4j"'H0	 [[1xb"'=>uhtR&<=htR&<=tXdB%;<xb"'=>uhtR&<=htR&<=tXdB%;<uhtR&<=	
B#B#H [[
8Aq!R,	-Aq!Q8O/PQ"	"$ [[' (3/0G (3/0G	
//r2   r  )r  r^  r  r6  r  )paramsc                     | j                   S )zIDay and some time units.

    * D
    * s
    * ms
    * us
    * ns
    )r  )r  s    r0   unitsrP  u  s     ==r2   c                  L    t        dd      j                         j                  S )Nr  rh  rd  )r   to_julian_daterC   r  r2   r0   julian_datesrS    s    j"-<<>EEEr2   c                   v   e Zd Zd Zd Zd Zd Zd Zej                  j                  dddg      d	        Zej                  j                  d
 eddd       eddd      d ej                  d      g      d        Zej                  j                  ddefdefdef eddd      efg      d        Zd Zd Zej                  j                  ddefddg      d        Zej                  j                  dg dg dg dg      d        Zej                  j                  d g d!g d"g d#g d$g      d%        Zy)&
TestOriginc                     t        ddd      }t        d      }||k(  sJ t        ddd      }t        d      }||k(  sJ y )Nr   r^  r  originz1970-01-01 00:00:02i ʚ;z2001-09-09 01:46:41rG   )r+   r  r/   s      r0   test_origin_and_unitzTestOrigin.test_origin_and_unit  sL    Q/23X~~];23X~~r2   c                     t        t        |dd            }t        t        |t        d      j                         z
  d            }t	        j
                  ||       y )Nr  julianrW  r   r  )r   r   r   rR  r)   rR   )r+   rS  r.   r/   s       r0   test_julianzTestOrigin.test_julian  sO     Ls8LMy|'B'B'DD3O
 	vx0r2   c                     t        t        g ddd            }t        t        d      t        d      t        d      gd	      }t        j                  ||       y )
N)r   r   r\   r  unixrW  z
1970-01-01r  r  rr   r"   r  r   s      r0   	test_unixzTestOrigin.test_unix  sM    ICGH|$i&=y?VW
 	vx0r2   c                     t        ddd      }|j                         dk(  sJ d}t        j                  t        |      5  t        ddd       d d d        y # 1 sw Y   y xY w)NiR|% r[  r  rX  r  z&1 is Out of Bounds for origin='julian'r^   r   )r   rR  ra   rb   rc   )r+   r.   r   s      r0   test_julian_round_tripz!TestOrigin.test_julian_round_trip  s]    WXC@$$&'111 7]]:S1 	6(5	6 	6 	6s   AA"c                     |dk7  r5d}t        j                  t        |      5  t        ||d       d d d        y y # 1 sw Y   y xY w)Nr  z$unit must be 'D' for origin='julian'r^   r[  rW  r   )r+   rP  rS  r   s       r0   test_invalid_unitzTestOrigin.test_invalid_unit  sL    C<8Cz5 GLuXFG G G Gs	   <Ar  r  r  c                     d}t        j                  t        |      5  t        dd|       d d d        y # 1 sw Y   y xY w)Nz(it must be numeric with a unit specifiedr^   z
2005-01-01
1960-01-01ra  r   )r+   r  r   s      r0   test_invalid_originzTestOrigin.test_invalid_origin  s<     9]]:S1 	F\E	F 	F 	Fs   6?epochs  r   rf  c           	      L   t        ddd      }t        j                  dt        j                        }|dk(  rdn|}t	        |D cg c]  }t        j                  ||      |z    c}d| d	      }t	        t        |||
            }t        j                  ||       y c c}w )Nri  r   rM   r"   r  r^  r  r  r=  rW  )
r   r%   r  r  r   r   	Timedeltar   r)   rR   )	r+   rP  rh  
epoch_1960units_from_epochsr@  rU   r/   r.   s	            r0   
test_epochzTestOrigin.test_epoch  s     tQ*
IIarxx83,3E?PQ!R\\!%(:5Qz#

 $5E&QR
vx0 Rs   !B!zorigin, excr  r  z
13-24-1990c                     dj                  d| dd| ddg      }t        j                  ||      5  t        t	        t        d            ||       d d d        y # 1 sw Y   y xY w)	Nr   zorigin z is Out of Boundsz# cannot be converted to a Timestampz,Cannot cast .* to unit='ns' without overflowr^   rM   rW  )r   ra   rb   r   r  ro  )r+   rX  excrP  r   s        r0   test_invalid_originszTestOrigin.test_invalid_origins  sq     hh&!23&!DE>
 ]]3c* 	CU1XU6B	C 	C 	Cs   !AA'c                     t        j                  t        d      5  t        ddt	        dddt
        j                               d d d        y # 1 sw Y   y xY w)Nzmust be tz-naiver^   r   r  r   r   rW  )ra   rb   rc   r   r   r   r   r  s    r0   test_invalid_origins_tzinfoz&TestOrigin.test_invalid_origins_tzinfo  sE    ]]:-?@ 	WHT1a,UV	W 	W 	Ws   *AAc                     d}t        j                  t        |      5  t        ddg       d d d        y # 1 sw Y   y xY w)Nz:Unknown datetime string format, unable to parse: yesterdayr^   r  	yesterdayr   r  s     r0   test_incorrect_value_exceptionz)TestOrigin.test_incorrect_value_exception  s7    J]]:S1 	0+./	0 	0 	0r   zformat, warningN)r   N)r   Nc                 ,   |St        d|      }t        |t              sJ |j                  dk(  sJ |j                  dk(  sJ |j
                  dk(  sJ y d}t        j                  t        |      5  t        d|       d d d        y # 1 sw Y   y xY w)Nz2417-10-10 00:00:00.00r   iq	  rh  z3unconverted data remains when parsing with format.*r^   )	r   r  r   r  r  r  ra   rb   rc   )r+   r?   r  r  r   s        r0   .test_to_datetime_out_of_bounds_with_format_argz9TestOrigin.test_to_datetime_out_of_bounds_with_format_arg  s     >6vFCc9---88t###99?"?77b= =GCz5 E4VDE E Es   3B

Bzarg, origin, expected_str)( r^  z2169-11-13 00:00:00)ry  
1870-01-012069-11-13 00:00:00)鼫 rz  2169-10-20 00:00:00c                     t        |d|      }t        |      }||k(  sJ t        ddd      }t        d      }||k(  sJ t        ddd      }t        d      }||k(  sJ y )Nr  rW  ry  rz  r{  r|  r}  rG   )r+   rH   rX  expected_strr.   r/   s         r0   test_processing_orderz TestOrigin.test_processing_order  sx     Ss6:\*!!!YSF23!!!YSF23!!!r2   zoffset,utc,exp)r  T2019-01-01T00:00:00.000Z)r  Nr  )-01:00Tz2019-01-01T01:00:00.000Z)r  Nz2019-01-01T00:00:00.000-01:00c                     d|z   }t        |gd|      }t        |g      j                  d      }t        j                  ||       y )Nz2019-01-01T00:00:00.000r  )r  r   r6  )r   r  r)   r*   )r+   r   r   r   rH   r.   r/   s          r0   test_arg_tz_ns_unitzTestOrigin.test_arg_tz_ns_unit  sE     (&0cU37u%--d3
fh/r2   )r   r   r   rY  r\  r_  rb  rd  ra   r   r   rg  r   r   r%   r  rn  rc   r   rq  rs  rv  r*  rx  r  r  r  r2   r0   rU  rU    s   116G [[VdC[1F 2F [[dAq!T1a BMM,'		

1
1 [[j)j!:&aA 34		
	C	CW
0 [[;''	
EE [[#6<<	
""  [[338=		
00r2   rU  c            
       J   e Zd Zej                  j                  dg ddfg ddfg      d        Zej                  j                  ddd	g      d
        Zej                  j                  d e e	d      gdz         e	d      gdz   e
 e	d      gdz        g      d        Zy)TestShouldCachezlistlike,do_caching)
r   r\   r   r   rM   r  r  r%  r$  r   F)
r   r   r   r   r   rM   r  r  r%  r$  Tc                 P    t        j                  |t        |      d      |k(  sJ y )Ngffffff?)check_countunique_share)r  should_cacher)  )r+   listlike
do_cachings      r0   test_should_cachez!TestShouldCache.test_should_cache.  s-     xS]QTU	
r2   z%unique_share,check_count, err_message)g      ?rg  z5check_count must be in next bounds: \[0; len\(arg\)\])rh  r\   z-unique_share must be in next bounds: \(0; 1\)c                     dgdz  }t        j                  t        |      5  t        j                  |||       d d d        y # 1 sw Y   y xY w)NrM   rh  r^   )ra   rb   AssertionErrorr  r  )r+   r  r  err_messagerH   s        r0   test_should_cache_errorsz(TestShouldCache.test_should_cache_errors;  sD     cBh]]>= 	?sL+>	? 	? 	?s   AAr  r5  r6  c                 6    t        j                  |      du sJ y )NT)r  r  )r+   r  s     r0   &test_no_slicing_errors_in_should_cachez6TestShouldCache.test_no_slicing_errors_in_should_cacheH  s     !!(+t333r2   N)r   r   r   ra   r   r   r  r  r   r   r  r  r  r2   r0   r  r  -  s    [[+U3+T2	


 [[/OE	
?? [[I345:;-./"4I345:;	
44r2   r  c            	         t        g dd      } | j                         }t        | d      }t        t        j                  d      t        j                  d      t        j                  d      t        j                  d	      t        j                  d      g      }t        j                  ||       t        j                  | |       y )
N)r   r\   Nl            NInt64r"   r  r  z1970-01-01 00:00:00.000000001z1970-01-01 00:00:00.000000002r   z2043-01-25 23:56:49.213693952)r   r  r   r%   r  r)   rR   )rT   ser_copyr  r/   s       r0   !test_nullable_integer_to_datetimer  U  s    
*'
:CxxzH
c
%CMM9:MM9:MM% MM9:MM% 	
H 3)3)r2   r  c                     t        | t              r7t        j                  t        d      5  t         || g             d d d        y t         || g            }|d   t        u sJ y # 1 sw Y   y xY w)Nznot convertible to datetimer^   r   )r  r   ra   rb   r  r   r   )nulls_fixturer  r.   s      r0   test_na_to_datetimer  j  si    -)]]9,IJ 	0}o./	0 	0 UM?34ayC	0 	0s   A((A1rp   rn   rv   zargs, format)z
03/24/2016z
03/25/2016r   r7   )
2016-03-24
2016-03-25r   r   r,  r  r-  c                     t        |      }t        |||       }t        ddt        gd      }t        j                  ||       y )Nr   r  r  r  r"   )r   r   r   r)   rR   )rp   r@  r?   r  r.   r/   s         r0   test_empty_string_datetimer  v  sA     
B F6:F|\37?OPH8V,r2   c                      t        ddgdd      } t        ddgd	      }t        j                  ||        t        ddgdd
      } t        j                  ||        y )Nr   r   r^  rv   r  z1970-01-01 00:00:01r   r  r"   rn   r   r.   r/   s     r0   'test_empty_string_datetime_coerce__unitr    s\     !Rs8<F3U;?SH(F+ !Rs7;F(F+r2   c                 ~   t         }t        t        d      |d      }|j                  dd      j	                  |d      }|j
                  j                         j                  t              d	z  |_        t        |j                  d d d
f   |       }|j                  d d d
f   }t        j                  ||       y )N1980YSr  FDTr  r   )nrandom_stater  r   r   )r   r   r   to_framesampler  	to_seriesr  rX   r   rU  r)   rR   )r@   cstarttimesr.   r/   s        r0   +test_to_datetime_monotonic_increasing_indexr    s    Fy(&tDENNTN299FQR9SE++'')007$>EKAqD)7Fzz!Q$H68,r2   series_length(   r   rM   c                    t        t        j                  d      gt        j                  d      g| z  z   t              }t	        |dd      }t        |D cg c]  }t        |       c}      }|j                  dk(  sJ t        j                  ||       t	        |dd      }t        j                  ||       y c c}w )	Nz1446-04-12 00:00:00+00:00z1991-10-20 00:00:00+00:00r"   rv   T)rp   r   M8[us, UTC]rn   )	r   r   fromisoformatr'   r   r   r#   r)   rR   )r  rT   r  rU   	expected1r  s         r0   2test_to_datetime_cache_coerce_50_lines_outofboundsr    s     			 ;	<=""#>?@=P	RC
 #hD9Gc2	!23I??m+++7I.#g48G7I. 3s   B<c            
      Z    d} d}t        | |      }t        ddddddd	d
      }||k(  sJ y )Nz15/02/2020 02:03:04.123456789z%d/%m/%Y %H:%M:%S.%fr   r  r\   r  r   r   r   i  )r  r  r  r  r  r  microsecondr,  rG   )r  timestamp_formatr.   r/   s       r0   %test_to_datetime_format_f_parse_nanosr    sL    /I-+;<F	H Xr2   c                  h    t        ddgd      } t        ddg      }t        j                  | |       y )Nr0  z2020-01-01 05:00:00r  r   rI  r   r  s     r0   test_to_datetime_mixed_iso8601r    s5    ,(=>yQF35JKLH&(+r2   c                  h    t        ddgd      } t        ddg      }t        j                  | |       y )Nz
01/11/2000z12 January 2000r  r   z
2000-01-11z
2000-01-12r   r  s     r0   test_to_datetime_mixed_otherr    s3    ,(9:7KFlL9:H&(+r2   r   TFr?   r  c                     d}t        j                  t        |      5  t        dg| |       d d d        y # 1 sw Y   y xY w)Nz8Cannot use 'exact' when 'format' is 'mixed' or 'ISO8601'r^   r0  )r   r?   r   )r   r?   r   s      r0   #test_to_datetime_mixed_or_iso_exactr    s?     EC	z	- @\N%?@ @ @r  c                      t        j                  t        d      5  t        ddgd       d d d        y # 1 sw Y   y xY w)Nz*Time data 01-01-2000 is not ISO8601 formatr^   r0  
01-01-2000r  r   r   r  r2   r0   4test_to_datetime_mixed_not_necessarily_iso8601_raiser    s9    	z)U	V D\<0CD D Dr  c                  n    t        ddgdd      } t        j                  | t        dt        g             y )Nr0  r  r  rv   r   rI  )r   r)   r*   r   r   )r.   s    r0   5test_to_datetime_mixed_not_necessarily_iso8601_coercer    s5    	|$YxF &-1F0L"MNr2   c                  D    t        ddd      } t        d      }| |k(  sJ y )N2023-10-15T14:30:00Tr  r   r?   2023-10-15 14:30:00+00:00rG   r  s     r0   )test_to_datetime_iso8601_utc_single_naiver    s*    .DKF45HXr2   c                      ddg} t        | dd      }t        t        d      t        d      g      }t        j                  ||       y )Nz2023-10-15T10:30:00-12:00r  Tr  r  z2023-10-15 22:30:00+00:00r  r   r   r   r)   r*   r   r.   r/   s      r0   2test_to_datetime_iso8601_utc_mixed_negative_offsetr    K    ')>?D4	:F	.	/;V1WXH &(+r2   c                      ddg} t        | dd      }t        t        d      t        d      g      }t        j                  ||       y )N2023-10-15T10:30:00+08:00r  Tr  r  2023-10-15 02:30:00+00:00r  r  r  s      r0   2test_to_datetime_iso8601_utc_mixed_positive_offsetr    r  r2   c                      g d} t        | dd      }t        t        d      t        d      t        d      g      }t        j                  ||       y )N)r  z2023-10-15T12:30:00-05:00r  Tr  r  r  z2023-10-15 17:30:00+00:00r  r  r  s      r0   /test_to_datetime_iso8601_utc_mixed_both_offsetsr    sU    D
 4	:F121212	
H &(+r2   c                  p   d} d}t        j                  t        |      5  t        |        d d d        t        j                  t        |      5  t	        |        d d d        t        j                  t        |      5  t	        | g       d d d        y # 1 sw Y   ixY w# 1 sw Y   FxY w# 1 sw Y   y xY w)Nz2014 Jan 9 05:15 FAKEz .*un-recognized timezone "FAKE".r^   )ra   rb   rc   r   r   )dtstrr   s     r0   test_unknown_tz_raisesr    s    #E
,C	z	- % 
z	- E	z	- UG    s#   BB >B,B B),B5c                      d\  } }t        | gt        z  |gz         }d}t        j                  t        |      5  t        |ddd       d d d        y # 1 sw Y   y xY w)N)z
2024-01-01Nz-time data "N" doesn't match format "%Y-%m-%d"r^   r   Tr   )r   r   ra   rb   rc   r   )validr  rT   r   s       r0   test_unformatted_input_raisesr  (  s^    &NE7
%++wi7
8C
:C	z	- DC
$dCD D Ds   AAc                     t        j                  d       t        ddg| j                          d      }t	        |      }t        ddgd      }t        j                  ||       y )Nr~  r   r\   z	[pyarrow]r"   r  )ra   r  r   lowerr   r)   rR   )any_numeric_ea_dtyperT   r.   r/   s       r0   test_from_numeric_arrow_dtyper  1  s]    
	"
!Q"6"<"<">!?yI
JCFq!f$45H68,r2   c                     ddg} t        | d      }t        t        d      dgd      }t        j                  ||       t        |       }t        j                  ||       t        |       }t        j                  ||       y )N2020-01-01 00:00+00:00r   r  r   r   r  r"   )r   r   r   r)   r*   r   )r  r.   r/   r  alt2s        r0   6test_to_datetime_with_empty_str_utc_false_format_mixedr  :  su    $b)Dg.Fi 895AWH&(+ d
C#x(D$)r2   c                      d} t        j                  t        |       5  t        g dd       d d d        y # 1 sw Y   y xY w)Nr   r^   )r  z2020-01-01 00:00+02:00r   r  r   r   )r   s    r0   Btest_to_datetime_with_empty_str_utc_false_offsets_and_format_mixedr  H  s7    
BC	z	- 
DW	

 
 
r  c                     t        dd      } d}| |g}d}t        j                  t        |      5  t	        |       d d d        t        j                  t        |      5  t	        |d       d d d        t        j                  t        |      5  t        |       d d d        y # 1 sw Y   jxY w# 1 sw Y   ExY w# 1 sw Y   y xY w)	Nz2016-01-02 03:04:05r   r   z2023-10-30 15:06+01sMixed timezones detected. Pass utc=True in to_datetime or tz='UTC' in DatetimeIndex to convert to a common timezoner^   r  r   )r   ra   rb   rc   r   r   )r  r  r-   r   s       r0   &test_to_datetime_mixed_tzs_mixed_typesr  R  s     
(\	:B!Eu+C	;  
z	- C	z	- )C()	z	- c 	 ) ) s#   B& B2B>&B/2B;>Cc                  d   d} t        |       }|| g}t        |      }t        |d d d         d d d   }t        |d      }t        |      }t        ||g      }t        j                  ||       t        j                  ||       t        j                  ||       t        j                  ||       y )Nz2023-11-01 09:22:03-07:00r(  r  r   r  )r  r  r-   r  r  res3res4r/   s           r0   )test_to_datetime_mixed_types_matching_tzsr  e  s    'E	5	Bu+CsDs4R4y!$B$'Ds7+DDb"X&H$)$)$)$)r2   r  z)ignore:Could not infer format:UserWarning	aware_valc                 ,    t        |       j                  S r  r  r   r<  s    r0   r=  r=  ~      $q'"" r2   	naive_valic                 ,    t        |       j                  S r  r  r<  s    r0   r=  r=    r  r2   naive_firstc                  
   | |dg}|}|r|| dg}t        | t              xr t        |t              }t        |t        t        f      }t        |t              xr t        | t              }d}t        d |D              }	t        |	t              s|}
|rRt        | t              rBt        |t              rd}
t        j                  t        |
      5  t        |       d d d        n5|s|rd}
t        j                  t        |
      5  t        |       d d d        t        |d       n|r|j                  |       |j                  |      k  rdd	}
t        j                  t        |
      5  t        |       d d d        t        j                  t        |
      5  t        |d       d d d        nN|r|j                  |       |j                  |      k  rcd
}
t        j                  t        |
      5  t        |       d d d        t        j                  t        |
      5  t        |d       d d d        n|r|j                  |      |j                  |       k  rcd}
t        j                  t        |
      5  t        |       d d d        t        j                  t        |
      5  t        |d       d d d        n>|}
t        j                  t        |
      5  t        |       d d d        t        |d       |rc|}
t        j                  t        |
      5  t        |d       d d d        t        j                  t        |
      5  t        |       d d d        y |}
|rt        | t              rst        |t              rd}
t        j                  t        |
      5  t        |d       d d d        t        j                  t        |
      5  t        |       d d d        y |s|rd}
t        j                  t        |
      5  t        |d       d d d        t        j                  t        |
      5  t        |       d d d        y # 1 sw Y   CxY w# 1 sw Y   PxY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w# 1 sw Y   /xY w# 1 sw Y   y xY w# 1 sw Y   xY w# 1 sw Y   y xY w)Nr   r  c              3   ,   K   | ]  }|d k7  s	|  yw)r   Nr  )rl  rU   s     r0   rm  z?test_to_datetime_mixed_awareness_mixed_types.<locals>.<genexpr>  s     4AG!4s   
z<Tz-aware datetime.datetime cannot be converted to datetime64r^   z(Cannot mix tz-aware with tz-naive valuesTr  z!time data .* doesn't match formatz3time data \"2020-01-01 00:00\" doesn't match formatz1unconverted data remains when parsing with formatr  r   )r  rQ   r  rX   r   nextr   ra   rb   rc   r   r  r   )r  r  r  r  vec	both_strshas_numericboth_datetime	mixed_msgfirst_non_nullr   s              r0   ,test_to_datetime_mixed_awareness_mixed_typesr  z  s+    y"%D
C)R( 9c*Iz)S/IIYe5Ky(3W
9h8WM	; 
 4S44N nc*:i;)Y/Tz5 !C ! ! =@z5 !C ! 	CT"	9-		)0DD1]]:S1 		]]:S1 	'&	' 	' 
syy+cii	.BBD]]:S1 		]]:S1 	'&	' 	' 
syy+cii	.BBA]]:S1 		]]:S1 	'&	' 	' ]]:S1 		 	CT"]]:S1 	-G,	-]]:S1 	#	 	 :i;)Y/Tz5 1C01z5 #c"# # =@z5 1C01z5 #c"# #y! !
! !	 		' 	'
	 		' 	'
	 		' 	'
	 		- 	-	 	1 1# #
1 1# #s   QQ)Q+Q82R!R:R)R,R9SS$SS,S8<TQQ(+Q58RRRR),R69SSSS),S58TTc                      t        t        j                  dd      g      } t        dgdd       }t	        j
                  | |       y )Nl   Mp_$psz1970-01-01 00:00:01.901901901r  r  r  r  s     r0   &test_to_datetime_wrapped_datetime64_psr    sA    "--t<=>F	()1AH &(+r2   c                     t        j                  d      }d}|j                  d| d      }|j                  d      d   }t	        t        |g      d|       }|j                  d   t        |      k(  sJ y )	Nz
lxml.etreez2025-02-05 16:59:57z<date>z</date>z/date/node()r   r   r>   )ra   r  XMLxpathr   r   rU  r   )r@   etreer^  noder   outs         r0   6test_to_datetime_lxml_elementunicoderesult_with_formatr    sp    -EA99vaS()D
**^
$Q
'C
fcUm,?u
MC88A;)A,&&&r2   )m__doc__r   collectionsr   r   r   r   r   decimalr   r  r  dateutil.parserr	   numpyr%   ra   pandas._libsr
   pandas._libs.tslibsr   r   pandas.compatr   r   pandas.errorsr   r   pandas.util._test_decoratorsutil_test_decoratorsr  pandas.core.dtypes.commonr   pandasr   r   r   r   r   r   r   r   r   r   pandas._testing_testingr)   pandas.core.arraysr   pandas.core.toolsr   r  pandas.core.tools.datetimesr   r   r  r  r    r	  r  r  r)  r  r  r  r  r'  rP  rS  rU  r  r  r   r   r&   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r%  r  r   rX   r  r  r  r  r2   r0   <module>r     s          !    * ) < 
 
 
  , 0 8  	F	' 
 F9U0 U0pN) N)b&N@ N@bU1 U1pT* T*n1 1<o1 o1d?I ?IDm/ m/` 34	 5	 F Fc0 c0L%4 %4P** 288T"23  4  GX#67	):6	):6 
	"  - 8-	,- 	,q04Dq4HJ/	/"$,, 4-0Iw#78@ 9 1@DO,,,&
D-*
&*" 	!u GH
Ie"  
 
3BZ%rwwy"''288U288_U"  
 u6[# 7 I[#|,'r2   