@@ -550,11 +550,17 @@ cpdef convert_to_tsobject(object ts, object tz=None):
550
550
trans = _get_transitions(tz)
551
551
deltas = _get_deltas(tz)
552
552
pos = trans.searchsorted(obj.value, side = ' right' ) - 1
553
- inf = tz._transition_info[pos]
554
553
555
- pandas_datetime_to_datetimestruct(obj.value + deltas[pos],
556
- PANDAS_FR_ns, & obj.dts)
557
- obj.tzinfo = tz._tzinfos[inf]
554
+ # statictzinfo
555
+ if not hasattr (tz, ' _transition_info' ):
556
+ pandas_datetime_to_datetimestruct(obj.value + deltas[0 ],
557
+ PANDAS_FR_ns, & obj.dts)
558
+ obj.tzinfo = tz
559
+ else :
560
+ inf = tz._transition_info[pos]
561
+ pandas_datetime_to_datetimestruct(obj.value + deltas[pos],
562
+ PANDAS_FR_ns, & obj.dts)
563
+ obj.tzinfo = tz._tzinfos[inf]
558
564
559
565
return obj
560
566
@@ -899,16 +905,25 @@ def _get_transitions(tz):
899
905
Get UTC times of DST transitions
900
906
"""
901
907
if tz not in trans_cache:
902
- arr = np.array(tz._utc_transition_times, dtype = ' M8[ns]' )
903
- trans_cache[tz] = arr.view(' i8' )
908
+ if hasattr (tz, ' _utc_transition_times' ):
909
+ arr = np.array(tz._utc_transition_times, dtype = ' M8[ns]' )
910
+ arr = arr.view(' i8' )
911
+ else :
912
+ arr = np.array([NPY_NAT + 1 ], dtype = np.int64)
913
+ trans_cache[tz] = arr
904
914
return trans_cache[tz]
905
915
906
916
def _get_deltas (tz ):
907
917
"""
908
918
Get UTC offsets in microseconds corresponding to DST transitions
909
919
"""
910
920
if tz not in utc_offset_cache:
911
- utc_offset_cache[tz] = _unbox_utcoffsets(tz._transition_info)
921
+ if hasattr (tz, ' _utc_transition_times' ):
922
+ utc_offset_cache[tz] = _unbox_utcoffsets(tz._transition_info)
923
+ else :
924
+ # static tzinfo
925
+ num = int (total_seconds(tz._utcoffset)) * 1000000000
926
+ utc_offset_cache[tz] = np.array([num], dtype = np.int64)
912
927
return utc_offset_cache[tz]
913
928
914
929
cdef double total_seconds(object td): # Python 2.6 compat
0 commit comments