
    i?                        d dl mZ d dlmZmZmZ d dlmZ d dlmZ d dl	Z	d dl
Z
d dlZ
d dlmZ d dlZd dlZd dlmZmZ d dlZd dlmZmZmZmZmZmZ d dlmZ d d	lmZ  G d
 d      Z  G d d      Z!y)    )annotations)datetime	timedeltatimezone)partial)
attrgetterN)gettz)astype_overflowsafe	timezones)DatetimeIndexIndex	Timestamp
date_rangeoffsetsto_datetime)period_arrayc            
         e Zd Zd Zd Zd Zej                  j                  d e	dddd	       e
j                  d
d      g      d        Zd Zd Zd Zd Zd Zej                  j                  dddiddidddg      d        Zej                  j                  dddiddidddg      d        Zd Zd Zd Zd Zd Zej                  j                  ddg ed d!d!      gg      d"        Zd# Zd$ Zd% Zej                  j                  d&d'd(g      d)        Zd* Zd+ Z ej                  j                  de!e"jF                  e"jH                  g      d,        Z%d- Z&d. Z'ej                  j                  dd/d0 e(jR                  d0       e*d1d02      jV                  g      d3        Z,ej                  j                  dg d4      d5        Z-d6 Z.ej                  j                  d7e/e0g      ej                  j                  d8e"jb                   e2e"jb                  e!9      e3g      ej                  j                  d:d;d<g      d=                      Z4d> Z5d? Z6d@ Z7dA Z8dB Z9dC Z:dD Z;dE Z<dF Z=ej                  j                  d e(jR                  dG       e>dG      g      dH        Z?ej                  j                  dIdGdJg      dK        Z@dL ZAej                  j                  dMdNdOg      dP        ZBej                  j                  dIdGdJg      dQ        ZCej                  j                  ddR e>dG      g      ej                  j                  dSdTdUg      ej                  j                  dVe*e0g      dW                      ZDej                  j                  dg dX      dY        ZEdZ ZFd[ ZGej                  j                  dd\d]g      d^        ZHy/)_TestDatetimeIndexc                    t        j                  dd      }t        |gd      }t        |j                  d      gd      }t	        j
                  ||       y )N   D
US/PacifictzM8[s])np
datetime64r   astypetmassert_index_equal)selfvalresultexpecteds       m/app/cer_product_mecsu/.venv/lib/python3.12/site-packages/pandas/tests/indexes/datetimes/test_constructors.pytest_from_dt64_unsupported_unitz1TestDatetimeIndex.test_from_dt64_unsupported_unit%   sH    mmAs#u6 #**W"5!6<H
fh/    c                   t        dddd      }d}t        j                  t        |      5  t	        |d        d d d        t        j                  t        |      5  t	        t        j                  |      d        d d d        d	}t        j                  t        |      5  t	        g d
d        d d d        y # 1 sw Y   xY w# 1 sw Y   JxY w# 1 sw Y   y xY w)N
2016-01-01
   UTCnsperiodsr   unitz:Passed data is timezone-aware, incompatible with 'tz=None'matchr   z3Cannot pass both a timezone-aware dtype and tz=NoneM8[ns, UTC]dtyper   )r   pytestraises
ValueErrorr   r   arrayr!   dtimsgs      r%   test_explicit_tz_nonez'TestDatetimeIndex.test_explicit_tz_none-   s    re$GJ]]:S1 	(#$'	( ]]:S1 	2"((3-D1	2 D]]:S1 	<"Md;	< 	<	( 	(	2 	2	< 	<s#   B<!C$C<CCCc                t   d}t        j                  t        |      5  t        t        j
                  t        d      gd       d d d        t        j                  t        |      5  t        t        j
                  t        d      j                  gd       d d d        y # 1 sw Y   ^xY w# 1 sw Y   y xY w)NQInferred frequency None from passed values does not conform to passed frequency Dr0   
2011-01-01r   freq)r5   r6   r7   r   pdNaTr   _valuer!   r;   s     r%   test_freq_validation_with_natz/TestDatetimeIndex.test_freq_validation_with_nat<   s    $ 	 ]]:S1 	G2669\#:;#F	G]]:S1 	N2669\#:#A#ABM	N 	N	G 	G	N 	Ns   'B"(1B."B+.B7indexr)      r   r,   r-   z1 Day)r.   c                    |j                   }|g d   }|j                  J |j                  |      }|j                  J y )N)r            r   )_datarA   _shallow_copy)r!   rG   r8   arrr#   s        r%   %test_shallow_copy_inherits_array_freqz7TestDatetimeIndex.test_shallow_copy_inherits_array_freqI   sG     O$xx$$S){{"""r'   c                <   t        t        j                  dddgd      }||j                  fD ]l  }t        j                  |      }t        j
                  |      }t        j                  |      }|||fD ]#  }t        |      }t        j                  ||       % n y )Nz
2015-01-01z1999-04-06 15:14:13
US/Easternr   )	r   rB   rC   rM   CategoricalIndexCategoricalSeriesr   r    )r!   r:   dtobjcicarrcserobjr#   s           r%   test_categorical_preserves_tzz/TestDatetimeIndex.test_categorical_preserves_tz[   s    VV\#8,GL
 399% 		3E $$U+B>>%(D99R=DD$' 3&s+%%fc23		3r'   c                2   t        j                  ddgd      }t        j                  t        d      5  t        |       d d d        t        j                  t        d      5  t        |       d d d        t        j                  t        d      5  t        t        |             d d d        t        j                  t        d      5  t        t        |             d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   ZxY w# 1 sw Y   y xY w)N2016Q12016Q2Qr@   zPeriodDtype data is invalidr0   )rB   PeriodIndexr5   r6   	TypeErrorr   r   r   r!   datas     r%    test_dti_with_period_data_raisesz2TestDatetimeIndex.test_dti_with_period_data_raisesl   s    ~~x2=]]9,IJ 	 $	  ]]9,IJ 		 ]]9,IJ 	.,t,-	. ]]9,IJ 	,T*+	, 	,	  	 	 		. 	.	, 	,s/   C)$C5DD)C25C>D
Dc                \   t        j                  dgd      }d}t        j                  t        |      5  t        |       d d d        t        j                  t        |      5  t        |       d d d        t        j                  t        |      5  t        t        j                  |             d d d        t        j                  t        |      5  t        t        j                  |             d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   dxY w# 1 sw Y   y xY w)Nr   zm8[ns]r4   z3timedelta64\[ns\] cannot be converted to datetime64r0   )	r   r8   r5   r6   ra   r   r   rB   TimedeltaIndex)r!   rc   r;   s      r%   %test_dti_with_timedelta64_data_raisesz7TestDatetimeIndex.test_dti_with_timedelta64_data_raises|   s    xx8,D]]9C0 	 $	  ]]9C0 		 ]]9C0 	3"++D12	3 ]]9C0 	1))$/0	1 	1	  	 	 		3 	3	1 	1s/   C>%D
DD">D
DD"D+c                    t        d      t        d      g}t        j                  j                  |      }t	        |      }t        |      t        u sJ |j                  |j                  k(  sJ y )Nz2012-05-01T01:00:00.000000z2016-05-01T01:00:00.000000)r   rB   arraysSparseArrayr   typer4   )r!   valuesrO   r#   s       r%   "test_constructor_from_sparse_arrayz4TestDatetimeIndex.test_constructor_from_sparse_array   sd     2323
 ii##F+sF|u$$$||syy(((r'   c                N   t        j                  t        ddd      t        ddt        j                  d      d      t        d      t         j                  t        d      gt        dddd      d	      }|j                  j                  j                  j                  dk(  sJ y )
N20130101rJ   r,   )r.   r/   rR   r-   20130103)r.   rA   r/   )dtdttzdt_with_nulldtns)rB   	DataFramer   zoneinfoZoneInfor   rC   rs   r4   r   key)r!   dfs     r%   test_construction_cachingz+TestDatetimeIndex.test_construction_caching   s    \\ QTB"h.?.?.MTX j)FFj)!
 #:qt$O
 ww}}##|333r'   kwargsr   zdtype.tzr4   r3   c           	         |}t        ddd|d      }|j                         D ci c]  \  }}| t        |      |       }}}t        |fi |}t	        j
                  ||       y c c}}w )Nrp   rH   hr,   r.   rA   r   r/   )r   itemsr   r   r   r    )r!   r|   tz_aware_fixturer   iry   r"   r#   s           r%   test_construction_with_altz,TestDatetimeIndex.test_construction_with_alt   sm    
 z132DI:@,,.Ihc3#z#q))IIq+F+
a( Js   A(c           	        |}t        ddd|d      }|j                  d       }|j                         D ci c]  \  }}| t        |      |       }}}d|v rKt	        |j
                  d      j                  |d         }t	        |fi |}t        j                  ||       t	        |j                  d       j
                  d      }	|j                  d       j                  d      }t        j                  |	|       d	}
t        j                  t        |

      5  t	        |j                  d       j
                  |j                  t        j                  d             d d d        y c c}}w # 1 sw Y   y xY w)Nrp   rH   r~   r,   r   r   r+   r   -cannot supply both a tz and a dtype with a tzr0   z	US/Hawaiir3   )r   
_with_freqr   r   r   asi8
tz_convertr   r    tz_localizer5   r6   r7   r4   rw   rx   )r!   r|   r   r   r   ry   r"   r#   r$   i2r;   s              r%   &test_construction_with_alt_tz_localizez8TestDatetimeIndex.test_construction_with_alt_tz_localize   sE   
 z132DILL:@,,.Ihc3#z#q))II6>"166e4??tMF$Q1&1H!!&(3 1==.33>==&2259
b(+ >]]:S1 	d#((gg$$[1	 	 J	 	s   E,AE22E;c                ~   t        t        d      t        d      gd      }t        t        d      t        d      gd      }t        j                  ||d       t        |t              sJ |j                  J t        t        dd	      t        d
d	      gd      }t        t        d      t        d
      gdd      }t        j                  ||d       t        |t              sJ |j                  J |j                  |j                  k(  sJ t        t        dd	      t        dd	      gd      }t        t        d      t        d      gdd      }t        j                  ||d       t        |t              sJ |j                  J |j                  |j                  k(  sJ t        t        d      t        d
d	      gd      }t        t        d      t        d
d	      gdd      }t        j                  ||d       t        |t              rJ t        t        dd	      t        d
d	      gd      }t        t        dd	      t        d
d	      gdd      }t        j                  ||d       t        |t              rJ d}t        j                  t        |      5  t        ddg       d d d        t        t        d      gd      }t        t        d      gd      }t        j                  ||d       t        |t              sJ |j                  J t        t        dd	      gd      }t        t        d      gdd      }t        j                  ||d       t        |t              sJ |j                  J |j                  |j                  k(  sJ y # 1 sw Y   xY w)Nr?   
2011-01-02idxnameTexact2011-01-01 10:00
Asia/Tokyor   2011-01-02 10:00r   r   rR   2011-08-01 10:00objectr4   r   z6Mixed timezones detected. Pass utc=True in to_datetimer0   z2013-11-02 22:00-05:00z2013-11-03 22:00-06:00)
r   r   r   r   r    
isinstancer   r5   r6   r7   )r!   r#   expr;   s       r%   ,test_construction_index_with_mixed_timezonesz>TestDatetimeIndex.test_construction_index_with_mixed_timezones   s   	,/<1HIPUV|$i&=>U
 	fc6&-000yy    ,>,> 
 )*I6H,IJ

 	fc6&-000yy$$$yyCFF""" ,>,> 
 )*I6H,IJ

 	fc6&-000yy$$$yyCFF""" ,-,> 
 ,-,> 
 	fc6fm444,>,> 
 ,>,> 
 	fc6fm444F]]:S1 	P35MNO	P 	,/0u=Y|45EB
fc6&-000yy    	"4FGeT)*+5
 	fc6&-000yy$$$yyCFF"""%	P 	Ps   2N33N<c           	     d   t        t        j                  t        d      t        j                  t        d      gd      }t	        t        j                  t        d      t        j                  t        d      gd      }t        j                  ||d       t        |t              sJ |j                  J t        t        j                  t        dd	      t        j                  t        d
d	      gd      }t	        t        j                  t        d      t        j                  t        d
      gdd      }t        j                  ||d       t        |t              sJ |j                  J |j                  |j                  k(  sJ t        t        dd	      t        j                  t        dd	      gd      }t	        t        d      t        j                  t        d      gdd      }t        j                  ||d       t        |t              sJ |j                  J |j                  |j                  k(  sJ t        t        j                  t        d      t        j                  t        d
d	      gd      }t        t        j                  t        d      t        j                  t        d
d	      gdd      }t        j                  ||d       t        |t              rJ t        t        j                  t        dd	      t        j                  t        d
d	      gd      }t        t        j                  t        dd	      t        j                  t        d
d	      gdd      }t        j                  ||d       t        |t              rJ t        t        j                  t        j                  gd      }t	        t        j                  t        j                  gd      }t        j                  ||d       t        |t              sJ |j                  J y )Nr?   r   r   r   Tr   r   r   r   r   r   rR   r   r   r   )	r   rB   rC   r   r   r   r    r   r   )r!   r#   r   s      r%   5test_construction_index_with_mixed_timezones_with_NaTzGTestDatetimeIndex.test_construction_index_with_mixed_timezones_with_NaT9  s   VVY|,bffi6MN
 VVY|,bffi6MN
 	fc6&-000yy    ,>,>	 
 ,-,-	 	
 	fc6&-000yy$$$yyCFF""" ,>,>
 
 )*BFFI>P4QR

 	fc6&-000yy$$$yyCFF""" ,-,>	 
 ,-,>	 	
 	fc6fm444,>,>	 
 ,>,>	 	
 	fc6fm444 'e4RVVRVV,59
fc6&-000yy   r'   c                   t        t        d      t        d      gd      }t        t        d      t        d      gd      }t        j                  ||d       t	        |t               sJ t        t        dd	      t        d
d	      gd      }t        t        d      t        d
      gdd      }t        j                  ||d       t	        |t               sJ t        t        dd	      t        dd	      gd      }t        t        d      t        d      gdd      }t        j                  ||d       t	        |t               sJ d}t        j                  t        |      5  t        t        dd	      t        d
d	      gd       d d d        t        t        d      t        d
d	      gdd      }t        t        dd	      t        d
d	      j                  d      gdd      }t        j                  ||       t        t        dd	      t        d
d	      gdd      }t        t        dd	      j                  d      t        d
d	      gdd      }t        j                  ||       t        t        dd	      t        d
d	      gdd      }t        j                  ||       y # 1 sw Y   'xY w)Nr?   r   r   r   Tr   r   r   r   r   r   rR   r   z!cannot be converted to datetime64r0   zM8[us, US/Eastern]r   )	r   r   r   r    r   r5   r6   r7   r   )r!   r#   r   r;   r:   r$   s         r%   *test_construction_dti_with_mixed_timezonesz<TestDatetimeIndex.test_construction_dti_with_mixed_timezones  s    |$i&=>U
 |$i&=>U
 	fc6&-000 ,>,> 
 )*I6H,IJ

 	fc6&-000 ,>,> 
 )*I6H,IJ

 	fc6&-000 2]]:S1 	0\B0\B 	 ,-,> 
 !,>,>II,W 
 	c8, ,>,> 
 !,>II,W,> 
 	c8, ,>,> '
 	c8,w	 	s   ,&J77Kc                z   t        d      t        j                  t        d      g}t        j                  t        |      t        |             t        j                  t        t        j                  |            t        t        j                  |                   t        j                  t        j                  t        d      g}t        j                  t        |      t        |             t        j                  t        t        j                  |            t        t        j                  |                   y )Nr?   z
2011-01-03)
r   rB   rC   r   r    r   r   r   r8   nan)r!   rO   s     r%   "test_construction_base_constructorz4TestDatetimeIndex.test_construction_base_constructor  s    &	,0GH
eCj-*<=
eBHHSM2M"((3-4PQvvrvvy67
eCj-*<=
eBHHSM2M"((3-4PQr'   c                    t        ddd      t        ddd      t        ddd      t        ddd      g}t        |d      }t        |      }t        j                  ||       t	        |       y )Ni  r   i  i  ip  M8[us]rf   )r   r   r   r    r   )r!   datesr   ress       r%   test_construction_outofboundsz/TestDatetimeIndex.test_construction_outofbounds  sj     T1a T1a T1a T1a 	
 E*El
c3'er'   rc   z
1400-01-01ix  r   c                    t        |       y )N)r   rb   s     r%   test_dti_date_out_of_rangez,TestDatetimeIndex.test_dti_date_out_of_range+  s     	dr'   c                ,   t        ddd      t        ddd      t        ddd      g}t        |t        j                               j                  }t        |t        j                               }t        g ddd	
      }t        j                  ||       y )Ni  r*         	   r@   )z
2013-10-07z
2013-10-08z
2013-10-09r   Br4   rA   )r   r   r   BDayrm   r   r    )r!   r   rc   r#   r$   s        r%   test_construction_with_ndarrayz0TestDatetimeIndex.test_construction_with_ndarray0  sw    $A&r1(=xbRS?TUU8??t',,.9 6hS
 	fh/r'   c                   t        j                  dd      }t        j                  |j                  d      g      }t	        |      j                  d      }t	        dgd      }t        j                  ||       t        j                  d       5  t	        |d	      }d d d        t	        dgd
      }t        j                  ||       y # 1 sw Y   .xY w)Nz2000-01-01 00:00:00r,   i8
US/Centralz2000-01-01T00:00:00zM8[ns, US/Central]rf   r+   r   r2   )	r   r   r8   viewr   r   r   r    assert_produces_warning)r!   r"   rm   r#   r$   s        r%   -test_integer_values_and_tz_interpreted_as_utcz?TestDatetimeIndex.test_integer_values_and_tz_interpreted_as_utc:  s    mm148388D>*+v&22<@ "7!8@TU
fh/ ''- 	5"6e4F	5 "7!8N
fh/	5 	5s   C

Cc           
     P   d}t        j                  t        |      5  t        d       d d d        d t	        d      D        }t        |      }t        t	        d      D cg c]  }t        ddd      t        |      z    c}      }t        j                  ||       t        j                  g d      }t        |      }t        |j                  d	            }t        j                  ||       t        |j                  d
      j                        j                  d      }t        j                  ||       t        j                  g d      }t        |      }t        |j                  d	            }t        j                  ||       t        |j                  d
      j                        j                  d      }t        j                  ||       d}t        j                  t        |      5  t        g dd       d d d        y # 1 sw Y   xY wc c}w # 1 sw Y   y xY w)Nz8DatetimeIndex\(\.\.\.\) must be called with a collectionr0   1/1/2000c              3  N   K   | ]  }t        d dd      t        |      z     yw)  r   N)r   r   ).0r   s     r%   	<genexpr>z>TestDatetimeIndex.test_constructor_coverage.<locals>.<genexpr>P  s"     Fqxa#il2Fs   #%r*   r   r   )
2000-01-01
2000-01-02z
2000-01-03Or,   us)r   r   rC   r>   )r   r   z
2000-01-04r   r@   )r5   r6   ra   r   ranger   r   r   r    r   r8   r   as_unitr   r7   )r!   r;   genr#   r   r$   strings	from_intss           r%   test_constructor_coveragez+TestDatetimeIndex.test_constructor_coverageJ  s   I]]9C0 	&*%	& GE"IFs# :?)DQXdAq!IaL0D
 	fh/ ((EFw' !45
fh/!("2"24"8"="=>FFtL	
i2 ((>?w' !45
fh/!("2"24"8"="=>FFtL	
i2$ 	 ]]:S1 	PD3O	P 	PE	& 	& E6	P 	Ps   H
! H1H
HH%rA   YSzW-SUNc           
        t        dd|      }t        dd|t        t        d                  }t        j                  ||       t        dd|d	      }t        j
                  |j                  |j                         t        d
d|      }t        dd|t        t        d                  }t        j                  ||       t        dd|d      }t        j
                  |j                  |j                         t        dd|      }t        dd|t        t        d                  }t        j                  ||       t        dd|d	      }t        j
                  |j                  |j                         t        dd|      }t        dd|t        t        d                  }t        j                  ||       t        dd|d      }t        j
                  |j                  |j                         y )Nz2013-01-01T00:00:00-05:00z2016-01-01T23:59:59-05:00r@   z2013-01-01T00:00:00z2016-01-01T23:59:59i)minutesrA   r   zAmerica/Limaz2013-01-01T00:00:00+09:00z2016-01-01T23:59:59+09:00i  r   z2013/1/1 0:00:00-5:00z2016/1/1 23:59:59-5:00z2013/1/1 0:00:00+9:00z2016/1/1 23:59:59+09:00)r   r   r   r   r    assert_numpy_array_equalr   )r!   rA   r   r$   expected_i8s        r%   $test_constructor_datetime64_tzformatz6TestDatetimeIndex.test_constructor_datetime64_tzformatq  s    ')D4
 !!	$/0	
 	c8, !#8t
 	##CHHk.>.>?')D4
 !!	#./	
 	c8, !#8t
 	##CHHk.>.>? 02JQUV!!	$/0	
 	c8, !#8t
 	##CHHk.>.>?02KRVW!!	#./	
 	c8, !#8t
 	##CHHk.>.>?r'   c                   t        ddgd      }t        ddg      j                  d      j                  d      }t        j                  ||       t        ddgd      j                  d      }t        j                  ||       y )N
2013-01-01
2013-01-02datetime64[ns, US/Eastern]rf   r,   rR   r   )r   r   r   r   r    )r!   r   r$   s      r%   test_constructor_dtypez(TestDatetimeIndex.test_constructor_dtype  s}    <(0L
 <67WT][& 	
 	c8,\<8\JRRSWX
c8,r'   c                   t        ddgd      }d}t        j                  t        |      5  t        |d       d d d        d}t        j                  t        |      5  t        |d	       d d d        d
}t        j                  t        |      5  t        |dd       d d d        t        |d      }t        j                  ||       y # 1 sw Y   xY w# 1 sw Y   mxY w# 1 sw Y   ExY w)Nr   r   r   rf   zNcannot supply both a tz and a timezone-naive dtype \(i\.e\. datetime64\[ns\]\)r0   datetime64[ns]zDdata is already tz-aware US/Eastern, unable to set specified tz: CETzdatetime64[ns, CET]r   CET)r   r4   )r   r5   r6   r7   ra   r   r    )r!   r   r;   r#   s       r%   )test_constructor_dtype_tz_mismatch_raisesz;TestDatetimeIndex.test_constructor_dtype_tz_mismatch_raises  s    <(0L

+ 	 ]]:S1 	7#%56	7 U]]9C0 	<#%:;	<=]]:S1 	M#%/KL	M s*FG
c6*	7 	7
	< 	<	M 	Ms#   C CC&CC#&C/c                    d}t        j                  t        |      5  t        ddg|       d d d        y # 1 sw Y   y xY w)NzUnexpected value for 'dtype'r0   r   rK   rf   )r5   r6   r7   r   )r!   r4   r;   s      r%   %test_constructor_invalid_dtype_raisesz7TestDatetimeIndex.test_constructor_invalid_dtype_raises  s:     -]]:S1 	/1a&.	/ 	/ 	/s	   7A c                n    t        d      }t        |g      }|j                  d   |j                  k(  sJ y )Nl   )b0Z4 r   )r   r   
nanosecond)r!   t1r   s      r%   test_000constructor_resolutionz0TestDatetimeIndex.test_000constructor_resolution  s4    EFRD!~~a BMM111r'   c                    t        dgd      }d}t        j                  t        |      5  t	        j
                  d      |_        d d d        y # 1 sw Y   y xY w)N2010r+   r   zCannot directly set timezoner0   r   )r   r5   r6   AttributeErrorrw   rx   r   r9   s      r%   test_disallow_setting_tzz*TestDatetimeIndex.test_disallow_setting_tz  sJ    VH/,]]>5 	5&&|4CF	5 	5 	5s   AANAmerica/Los_Angeles2000r   c                    t        dd      }t        dd      }t        d|||d      }t        ddgdd	      }t        j                  ||       t        j                  d      |j                  u sJ y )
Nz2013-01-01 06:00:00r   r   z2013-01-02 06:00:00r   r,   )rA   startendr   r/   zM8[ns, America/Los_Angeles]r   )r   r   r   r   r    rw   rx   r   )r!   r   r   r   r#   r$   s         r%   "test_constructor_start_end_with_tzz4TestDatetimeIndex.test_constructor_start_end_with_tz  s{     /4IJ-2GHEsrM "$9:/

 	fh/  !67699DDDr'   )r   rR   r   c                    t        j                  d      }|j                  |      }t        d|      j                  }t        dg|      }|j                  |      |j                  u sJ y )Npytzr   r   )r5   importorskipr   r   r   r   )r!   r   r   tz_innon_norm_tzr#   s         r%   )test_constructor_with_non_normalized_pytzz;TestDatetimeIndex.test_constructor_with_non_normalized_pytz  s]     ""6*b!5144xK8}}R FII---r'   c                   t        dd      t        dd      g}t        |      j                  d      }t        |d   j                         |d   j                         g      j                  d      }t	        j
                  ||       y )Nz2016-10-30 03:00:00+0300zEurope/Helsinkir   z2016-10-30 03:00:00+0200r,   r   r   )r   r   r   to_pydatetimer   r    )r!   tsr#   r$   s       r%   #test_constructor_timestamp_near_dstz5TestDatetimeIndex.test_constructor_timestamp_near_dst  s     05FG05FG
 r"**40 U  "BqE$7$7$9:

'$- 	 	fh/r'   klassboxrf   z	tz, dtype)r   zdatetime64[ns, US/Pacific])Nr   c                    t        d|      j                  d      } | ||j                  g      |      } ||g      }||k(  sJ y )Nz
2018-01-01r   r,   rf   )r   r   rD   )r!   r   r   r   r4   r   r#   r$   s           r%   test_constructor_with_int_tzz.TestDatetimeIndex.test_constructor_with_int_tz  sK     |+33D9sBII;'u5";!!!r'   c                P    |}d}t        |g|      j                  d   }||k(  sJ y )Nl     _S r   r   )r   r   )r!   tz_naive_fixturer   r#   r$   s        r%   test_construction_int_rountripz0TestDatetimeIndex.test_construction_int_rountrip$  s3    $ &b166q9!!!r'   c           	        t        t        ddd      t        ddd      ddd      }t        |D cg c]  }|j                  d	d
       c}      }t        g dd      j	                  d      }t        j                  ||       y c c}w )Nr           zYE-DECzAustralia/Melbourner,   )rA   r   r/      r   )monthday)z2000-06-01 00:00:00z2001-06-01 00:00:00z2002-06-01 00:00:00z2003-06-01 00:00:00z2004-06-01 00:00:00z2005-06-01 00:00:00r   )r   r   r   replacer   r   r    )r!   rG   xr#   r$   s        r%   3test_construction_from_replaced_timestamps_with_dstzETestDatetimeIndex.test_construction_from_replaced_timestamps_with_dst,  s    dB#dB#$
 5Ia		q	 9IJ  %

 '$- 	 	fh/  Js   Bc                    t        ddd      }d}t        j                  t        |      5  t	        |d       d d d        y # 1 sw Y   y xY w)	Nr)   rJ   r   )r.   r   z?data is already tz-aware US/Central, unable to set specified tzr0   r   r   )r   r5   r6   ra   r   r9   s      r%   *test_construction_with_tz_and_tz_aware_dtiz<TestDatetimeIndex.test_construction_with_tz_and_tz_aware_dtiC  sB    q\BO]]9C0 	0#,/	0 	0 	0s   AAc                   t         j                  j                         }t        ddg|      j	                  d      }t        t        d|      t        j                  g      j	                  d      }t        j                  ||       y )N2018rC   r   r,   )
dateutilr   tzlocalr   r   r   rB   rC   r   r    )r!   r   r#   r$   s       r%   &test_construction_with_nat_and_tzlocalz8TestDatetimeIndex.test_construction_with_nat_and_tzlocalJ  sd    [[  "26>>tD )Fr":BFF!CDLLTR
fh/r'   c                B   t        ddgddd      }d}t        dd	d
d
      j                  |d      }t        |ddd      }t	        j
                  ||       d}t        dd	dd
      j                  |d      }t        |ddd      }t	        j
                  ||       y )Nz2020-11-01 01:00:00z2020-11-02 01:00:00z datetime64[ns, America/New_York]r   F)r4   rA   	ambiguouszAmerica/New_Yorki     r   )yearr   r   hour)r  rK   r,   )r   r.   r  r/   )r   r.   r  r/   )r   r   r   r   r   r    )r!   r$   r   r   r#   r   s         r%   +test_constructor_with_ambiguous_keyword_argz=TestDatetimeIndex.test_constructor_with_ambiguous_keyword_argP  s     !"$9:4	
 &t211=II J 
 %e$O
fh/ &T;GG H 
 Q%dK
fh/r'   c                   |}t        d      j                  |d      }t        |ddd      }t        t        d|	      t        d
|	      g      j	                  d      }t        j                  ||       |}t        |ddd      }t        t        d|	      t        d|	      g      j	                  d      }t        j                  ||       y )Nz2015-03-29 02:30:00shift_forward)nonexistentrK   r~   r,   )r   r.   rA   r/   z2015-03-29 03:00:00+02:00r   z2015-03-29 04:00:00+02:00)r   r.   rA   r/   z2015-03-29 01:00:00+01:00)r   r   r   r   r   r   r    )r!   warsawr   r   r#   r$   r   s          r%   -test_constructor_with_nonexistent_keyword_argz?TestDatetimeIndex.test_constructor_with_nonexistent_keyword_argj  s     /0<</ = 
 %4H 5(C5(C

 '$- 	 	fh/ QStD 5(C5(C

 '$- 	 	fh/r'   c                   d}t        j                  t        |      5  t        dgd       d d d        d}t        j                  t        |      5  t	        dgd       d d d        y # 1 sw Y   >xY w# 1 sw Y   y xY w)Nz with no precision is not allowedr0   r   r   rf   z2The 'datetime64' dtype has no unit. Please pass in)r5   r6   r7   r   r   rE   s     r%   $test_constructor_no_precision_raisesz6TestDatetimeIndex.test_constructor_no_precision_raises  st     1]]:S1 	86(,7	8 C]]:S1 	06(,/	0 	0		8 	8	0 	0s   A*A6*A36A?c                l    t        dgd      }|j                  dk(  sJ |d   t        ddd      k(  sJ y )Nr   zdatetime64[us]rf   r   r   r   r   )r   r4   r   )r!   r:   s     r%   'test_constructor_wrong_precision_raisesz9TestDatetimeIndex.test_constructor_wrong_precision_raises  s>    VH,<=yyH$$$1v4A....r'   c                    t        t        j                  t        dd      t        j                  gt
                    }t        t        dd      t        j                  g      }t        j                  ||       y )N2019r+   r   rf   )r   r   r8   r   r   r   r   rB   rC   r   r    )r!   r#   r$   s      r%   Htest_index_constructor_with_numpy_object_array_and_timestamp_tz_with_nanzZTestDatetimeIndex.test_index_constructor_with_numpy_object_array_and_timestamp_tz_with_nan  sQ    rxx6e!<bff EVTU )Fu"=rvv!FG
fh/r'   rR   c                ~    t        ddd|      g}t        |      }t        j                  |j                  |      sJ y )N  r      )tzinfo)r   r   r   
tz_comparer   )r!   r   drG   s       r%   test_dti_from_tzaware_datetimez0TestDatetimeIndex.test_dti_from_tzaware_datetime  s;     dAr"-.a ##EHHb111r'   tzstrzdateutil/US/Easternc                `   ddg}t        |      j                  |      }t        ddd|d      }|j                  d      }t	        ||	      }t	        t        j                  |      |	      }t        j                  ||       t        j                  ||       t        j                  ||       y)
z^Test different DatetimeIndex constructions with timezone
        Follow-up of GH#4229
        z11/10/2005 08:00:00z11/10/2005 09:00:00z2005-11-10 08:00:00r~   rK   r   )r   rA   r.   r   r/   Nr   )	r   r   r   r   r   r   r8   r   r    )r!   r$  rO   idx1idx2idx3idx4s          r%   test_dti_tz_constructorsz*TestDatetimeIndex.test_dti_tz_constructors  s    
 %&;<3++E2'c1T
 t$SU+RXXc]u5
dD)
dD)
dD)r'   c                j    t        dddd|      }t        |d      }t        j                  ||       y )Nz03/12/2012 00:00r*   zW-FRIrR   r   )rc   r   r   r   r   r    )r!   r/   rngrng2s       r%    test_dti_construction_idempotentz2TestDatetimeIndex.test_dti_construction_idempotent  s6    \PT
 #,7
c4(r'   prefix z	dateutil/c                ^    t        t        ddd      g|dz         }|j                   |d    y )Nr  r   ESTr   r   )r   r   r  )r!   r0  rG   s      r%   "test_dti_constructor_static_tzinfoz4TestDatetimeIndex.test_dti_constructor_static_tzinfo  s.     xa34%H

ar'   c                |    t        dd|d      }t        t        |      dd      }t        j                  ||       y )Nz
2012-06-02r*   foo)r.   r   r   r   )r   rA   )r   r   listr   r    )r!   r$  drdr2s       r%   test_dti_convert_datetime_listz0TestDatetimeIndex.test_dti_convert_datetime_list  s4    bUGDH5s;
b#&r'   zpytz/US/Easternuse_strTFbox_clsc                &   t        |t              rF|j                  d      r5t        j                  d      }|j                  |j                  d            }d}|}|st        |      j                         }|t        ur|g}|sUt        |t        j                  j                        r1t        j                  j                  d      }|j                  |       t        j                  t         |      5   |||       d d d        y # 1 sw Y   y xY w)Nzpytz/r   z2013-11-03 01:59:59.999999zWe implicitly get fold=0.)reasonr0   r   )r   str
startswithr5   r   r   removeprefixr   r   r  r   tzfilemarkxfailapplymarkerr6   r7   )	r!   r   r;  r<  requestr   dtstritemrC  s	            r%   $test_dti_ambiguous_matches_timestampz6TestDatetimeIndex.test_dti_ambiguous_matches_timestamp  s     b#2==#9&&v.Drw78B,U#113D)#6D:b(++*<*<=
 ;;$$,G$HD%]]:U3 	!DR 	! 	! 	!s   3DD)Nr+   r   c                b   t        d      }d}|d| d}|ddg}t        ||      }|d   j                  |      t        |d	   |
      t        |d   dd      j	                  |      g}|D cg c]  }|j                  d      j                   }}t        j                  |d      }	t        |	d      }
| |
j                  d      j	                  |      }
t        j                  ||
       t        t        j                  |t              |      }t        j                  ||
       y c c}w )Nz
2999-01-01r   zM8[us, ]z2999-01-02 03:04:05.678910i	  rf   r   r   r   rK   r   T)r/   utcr+   )r   r   r   r   r   r   asm8r   r8   r   r    r   )r!   r   r   r4   valsr#   	pointwiser  exp_valsexp_arrr$   result2s               r%   (test_dti_constructor_with_non_nano_dtypez:TestDatetimeIndex.test_dti_constructor_with_non_nano_dtype  s    |$>bTOE0$7t51
 G#d1g"%Qd5@@D
	
 3<<QAIIdO((<<((884 9>++E2==bAH
fh/V <EJ
gx0 =s   /"D,c                @   t        j                         }t        j                         }t        ddgd      }|j                  dk(  sJ |d   |j                  d      z
  }|d   |j                  d      z
  }|t        j                  d      k\  s
J d|        |t        j                  d      k\  s
J d|        |j                  t        j                  j                  d	d
             t        j                  d      }||k  s
J d|        ||k  s
J d|        y )Nnowtodayr   rf   r   sr   zThe difference is z)result may not exactly match [now, today]F)r>  strict)seconds)r   rU  rV  r   r4   r   rB   	TimedeltarE  r5   rC  rD  )r!   rF  rU  rV  r#   diff0diff1	tolerances           r%   ,test_dti_constructor_with_non_nano_now_todayz>TestDatetimeIndex.test_dti_constructor_with_non_nano_now_today
  s"   mmo!w/w?||w&&&q	CKK,,q	EMM#..Q'E+=eW)EE'Q'E+=eW)EE'
 	KKB5  	

 LL+	y >$6ug">> y >$6ug">> r'   c                    t        j                  dt         j                  gt         j                        }|j	                  t
              }t        |d      }t        |d      }t        j                  ||       y )Nr   rf   r   r   )	r   r8   r   float64r   r   r   r   r    )r!   rO   arr2dti1dti2s        r%   5test_dti_constructor_object_float_matches_float_dtypezGTestDatetimeIndex.test_dti_constructor_object_float_matches_float_dtype"  sT    hh266{"**5zz&!SU+Te,
dD)r'   r   zM8[us, US/Pacific]c                   t        j                  dd      dz  }t        j                  j                  |d<   |j                  t         j                        }t         j                  |d<   |j                  t              }t        j                  |d<   |j                  t              }t        ||      }t        ||      }t        ||      }t        ||      }	t        |j                  d            }
|j                  *|
j                  d      j                  |j                        }
t        j                  ||
       t        j                  ||
       t        j                  ||
       t        j                  |	|
       y )NrH   r   rf     r   r   r+   )r   arangerB   rC   valuer   r`  r   r   r   r   r   r   r   r   r    )r!   r4   vals1vals2vals3vals4res1res2res3res4r$   s              r%   <test_dti_constructor_with_dtype_object_int_matches_int_dtypezNTestDatetimeIndex.test_dti_constructor_with_dtype_object_int_matches_int_dtype+  s     		!4(4/66<<aRZZ(66aV$ 66aV$U%0U%0U%0U%0 H!5677++E2==dggFH
dH-
dH-
dH-
dH-r'   )I__name__
__module____qualname__r&   r<   rF   r5   rC  parametrizer   rB   timedelta_rangerP   r[   rd   rh   rn   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   int32int64r   r   r   rw   rx   r   r   r   r   r   r   r   r8   r   r7  r   r   r  r  r
  r  r  r  r  r  r	   r#  r*  r/  r4  r:  rI  rS  r^  rd  rq   r'   r%   r   r   $   s   0<
N [[|Q<dKBw2	
	#	#3", 1 	)4" [[

	gw/7*1UV)	) [[

	gw/7*1UV	4f#Pl!\k-ZR [[V|nxa7K6L%MN O00 %PN [[VdG_5;@ 6;@z-+0 [[Wvrxx&BC/ D/25 [[!H34f!67::		
EE [[T#MN. O.
0 [[Wum&<=[[URXXwrxxv/NPT$UV[[	57OP"	 W >""0.00040<	0/
0 [[ x  .l0CD22 [[W|5J&KL* M*$) [[XK'89 : [[W|5J&KL' M'
 [[,	
 [[Yu6[[YM(BC! D 7!0 [[T#>?1 @14?0* [[Wx1E&FG. H.r'   r   c                      e Zd Zd Zd Zd Zd Zd Zd Ze	j                  j                  dg d      d	        Zd
 Zd Zy)TestTimeSeriesc                l    t        ddd      }t        |      }|j                  |j                  k(  sJ y Nr   z1/2/20005minr@   )r   r   rA   )r!   r-  r.  s      r%   &test_dti_constructor_preserve_dti_freqz5TestTimeSeries.test_dti_constructor_preserve_dti_freqK  s0    Zf=S!xx499$$$r'   c                    t        ddd      }t        |d       }|j                  J t        |j                  d       }|j                  J y r}  )r   r   rA   rM   )r!   r-  r#   s      r%   test_explicit_none_freqz&TestTimeSeries.test_explicit_none_freqQ  sL    Zf=s.{{"""syyt4{{"""r'   c                    t        g d      }t        j                  g d|      }t        j                  t        |      |       y )N)z1970-01-01 00:00:00.00000000z1970-01-01 00:00:00.00000001z1970-01-01 00:00:00.00000002)r   r*      rf   )r   r   r8   r   r    )r!   any_int_numpy_dtyper   rO   s       r%   test_dti_constructor_small_intz-TestTimeSeries.test_dti_constructor_small_int[  s9    
 hh{*=>
mC0#6r'   c                D    t        dg      }|d   j                  dk(  sJ y )Nz1-1-2000 00:00:01r   r   )r   second)r!   r-  s     r%   test_ctor_str_intradayz%TestTimeSeries.test_ctor_str_intradayh  s&    0121v}}!!!r'   c                    t        j                  dddt         j                        j                  d      }t	        |      }|j
                  t        |t        j                  d            k(  j                         sJ y )Nr   d   r*   rf   zM8[D]zM8[ns])	r   rg  rx  r   r   rm   r
   r4   all)r!   rO   r   s      r%   &test_index_cast_datetime64_other_unitsz5TestTimeSeries.test_index_cast_datetime64_other_unitsl  sZ    ii3"((388ACj

1#RXXh=OPPUUWWWr'   c                h   t        j                  dt         j                        }t        |d      }d|dd |j                  dd dk(  j                         sJ t        j                  dt         j                        }t        |d      }d|dd |j                  dd dk7  j                         sJ y )	Nrf  rf   F)copy2   r  T)r   rg  rx  r   r   r  )r!   rO   rG   s      r%   test_constructor_int64_nocopyz,TestTimeSeries.test_constructor_int64_nocopyr  s    iiBHH-c.Bs

2c"b(--///iiBHH-c-Bs

2c"b(--///r'   rA   )MEQEYEr   r   bhminrW  msr   r~   r,   Cc                    t        d|d      }t        ||      }t        j                  ||       t        d|dd      }t        ||d      }t        j                  ||       y )Nz2001/02/01 09:00r   )r   rA   r.   r@   r   )r   rA   r   r.   r   r,  )r!   rA   orgr   s       r%   !test_from_freq_recreate_from_dataz0TestTimeSeries.test_from_freq_recreate_from_data  sb    
 1aHCd+
c3'$4L!
 Cd|<
c3'r'   c                >   g d}d}t        j                  t        |      5  t        |       d d d        g d}t        |      }t	        ddd      ddd	g}t        |      }t        t	        ddd            ddd	g}t        |      }t        j                  g dd
      }t        |      }t        ddgd      }t        ddgdd      }t        j                  ||       |||fD ]+  }	|j                  |	j                  k(  j                         r+J  y # 1 sw Y   xY w)N)1/1/20051/2/2005z
Jn 3, 2005
2005-01-04z9(\(')?Unknown datetime string format(:', 'Jn 3, 2005'\))?r0   )r  r  1/3/2005r  r   r   r  r  r  r   rf   z
12/05/2007z
25/01/2008T)dayfirstz
2007/05/12z
2008/01/25F)r  	yearfirst)r5   r6   r7   r   r   r   r   r8   r   r    rm   r  )
r!   rO   r;   r&  r'  r(  r)  idx5idx6others
             r%   #test_datetimeindex_constructor_miscz2TestTimeSeries.test_datetimeindex_constructor_misc  s   BJ]]:S1 	#	 AS!a#Z\JS!$1-.
JUS!hhIQTUS!lL9DI<(5D
 	dD)D$' 	7EKK5<</44666	7+	 	s   DDc                   d}t        dddd      }t        dddd      }t        |gdd	
      }t        |g      }t        j                  ||       t        |gdd	      }t        |g      }t        j                  ||       y )Nz5/10/16i  r*   rH   r   r   r      T)r   r  )r   r  )r   r   r   r    )r!   r"   dfirstyfirstresult1	expected1rR  	expected2s           r%   <test_dti_constructor_object_dtype_dayfirst_yearfirst_with_tzzKTestTimeSeries.test_dti_constructor_object_dtype_dayfirst_yearfirst_with_tz  s    4Q<84RL9,F!6(+	
gy1,$G!6(+	
gy1r'   N)rr  rs  rt  r  r  r  r  r  r  r5   rC  ru  r  r  r  ry  r'   r%   r{  r{  J  sT    %#7"X0 [[R	(		(762r'   r{  )"
__future__r   r   r   r   	functoolsr   operatorr   rw   r  dateutil.tzr	   numpyr   r5   pandas._libs.tslibsr
   r   pandasrB   r   r   r   r   r   r   pandas._testing_testingr   pandas.core.arraysr   r   r{  ry  r'   r%   <module>r     sa    " 
        
    +c. c.L!m2 m2r'   