@@ -535,7 +535,6 @@ def _generate(cls, start, end, periods, name, freq,
535535 freq = freq , name = name )
536536 else :
537537 index = _generate_regular_range (start , end , periods , freq )
538-
539538 else :
540539
541540 if tz is not None :
@@ -559,12 +558,13 @@ def _generate(cls, start, end, periods, name, freq,
559558 freq = freq , name = name )
560559 else :
561560 index = _generate_regular_range (start , end , periods , freq )
562-
563561 if tz is not None and getattr (index , 'tz' , None ) is None :
564- index = conversion .tz_localize_to_utc (_ensure_int64 (index ),
565- tz ,
566- ambiguous = ambiguous )
567- index = index .view (_NS_DTYPE )
562+ arr = conversion .tz_localize_to_utc (_ensure_int64 (index ),
563+ tz ,
564+ ambiguous = ambiguous )
565+
566+ arr = arr .view (_NS_DTYPE )
567+ index = DatetimeIndex (arr )
568568
569569 # index is localized datetime64 array -> have to convert
570570 # start/end as well to compare
@@ -585,7 +585,9 @@ def _generate(cls, start, end, periods, name, freq,
585585 index = index [1 :]
586586 if not right_closed and len (index ) and index [- 1 ] == end :
587587 index = index [:- 1 ]
588- index = cls ._simple_new (index , name = name , freq = freq , tz = tz )
588+
589+ index = cls ._simple_new (index .values , name = name , freq = freq , tz = tz )
590+
589591 return index
590592
591593 @property
@@ -619,9 +621,6 @@ def _simple_new(cls, values, name=None, freq=None, tz=None,
619621 if we are passed a non-dtype compat, then coerce using the constructor
620622 """
621623
622- if isinstance (values , DatetimeIndex ):
623- values = values .values
624-
625624 if getattr (values , 'dtype' , None ) is None :
626625 # empty, but with dtype compat
627626 if values is None :
0 commit comments