@@ -538,7 +538,6 @@ def _generate(cls, start, end, periods, name, freq,
538
538
freq = freq , name = name )
539
539
else :
540
540
index = _generate_regular_range (start , end , periods , freq )
541
-
542
541
else :
543
542
544
543
if tz is not None :
@@ -562,12 +561,13 @@ def _generate(cls, start, end, periods, name, freq,
562
561
freq = freq , name = name )
563
562
else :
564
563
index = _generate_regular_range (start , end , periods , freq )
565
-
566
564
if tz is not None and getattr (index , 'tz' , None ) is None :
567
- index = conversion .tz_localize_to_utc (_ensure_int64 (index ),
568
- tz ,
569
- ambiguous = ambiguous )
570
- index = index .view (_NS_DTYPE )
565
+ arr = conversion .tz_localize_to_utc (_ensure_int64 (index ),
566
+ tz ,
567
+ ambiguous = ambiguous )
568
+
569
+ arr = arr .view (_NS_DTYPE )
570
+ index = DatetimeIndex (arr )
571
571
572
572
# index is localized datetime64 array -> have to convert
573
573
# start/end as well to compare
@@ -588,7 +588,9 @@ def _generate(cls, start, end, periods, name, freq,
588
588
index = index [1 :]
589
589
if not right_closed and len (index ) and index [- 1 ] == end :
590
590
index = index [:- 1 ]
591
- index = cls ._simple_new (index , name = name , freq = freq , tz = tz )
591
+
592
+ index = cls ._simple_new (index .values , name = name , freq = freq , tz = tz )
593
+
592
594
return index
593
595
594
596
@property
@@ -622,9 +624,6 @@ def _simple_new(cls, values, name=None, freq=None, tz=None,
622
624
if we are passed a non-dtype compat, then coerce using the constructor
623
625
"""
624
626
625
- if isinstance (values , DatetimeIndex ):
626
- values = values .values
627
-
628
627
if getattr (values , 'dtype' , None ) is None :
629
628
# empty, but with dtype compat
630
629
if values is None :
0 commit comments