@@ -49,30 +49,30 @@ from pandas._libs.tslibs.tzconversion cimport (
49
49
50
50
cdef inline object create_datetime_from_ts(
51
51
int64_t value, npy_datetimestruct dts,
52
- object tz, object freq):
52
+ object tz, object freq, bint fold ):
53
53
""" convenience routine to construct a datetime.datetime from its parts """
54
54
return datetime(dts.year, dts.month, dts.day, dts.hour,
55
55
dts.min, dts.sec, dts.us, tz)
56
56
57
57
58
58
cdef inline object create_date_from_ts(
59
59
int64_t value, npy_datetimestruct dts,
60
- object tz, object freq):
60
+ object tz, object freq, bint fold ):
61
61
""" convenience routine to construct a datetime.date from its parts """
62
62
return date(dts.year, dts.month, dts.day)
63
63
64
64
65
65
cdef inline object create_time_from_ts(
66
66
int64_t value, npy_datetimestruct dts,
67
- object tz, object freq):
67
+ object tz, object freq, bint fold ):
68
68
""" convenience routine to construct a datetime.time from its parts """
69
69
return time(dts.hour, dts.min, dts.sec, dts.us, tz)
70
70
71
71
72
72
@ cython.wraparound (False )
73
73
@ cython.boundscheck (False )
74
74
def ints_to_pydatetime (const int64_t[:] arr , object tz = None , object freq = None ,
75
- str box = " datetime" ):
75
+ bint fold = 0 , str box = " datetime" ):
76
76
"""
77
77
Convert an i8 repr to an ndarray of datetimes, date, time or Timestamp
78
78
@@ -104,7 +104,7 @@ def ints_to_pydatetime(const int64_t[:] arr, object tz=None, object freq=None,
104
104
str typ
105
105
int64_t value, delta, local_value
106
106
ndarray[object ] result = np.empty(n, dtype = object )
107
- object (* func_create)(int64_t, npy_datetimestruct, object , object )
107
+ object (* func_create)(int64_t, npy_datetimestruct, object , object , bint )
108
108
109
109
if box == " date" :
110
110
assert (tz is None ), " tz should be None when converting to date"
@@ -129,7 +129,7 @@ def ints_to_pydatetime(const int64_t[:] arr, object tz=None, object freq=None,
129
129
result[i] = < object > NaT
130
130
else :
131
131
dt64_to_dtstruct(value, & dts)
132
- result[i] = func_create(value, dts, tz, freq)
132
+ result[i] = func_create(value, dts, tz, freq, fold )
133
133
elif is_tzlocal(tz):
134
134
for i in range (n):
135
135
value = arr[i]
@@ -141,7 +141,7 @@ def ints_to_pydatetime(const int64_t[:] arr, object tz=None, object freq=None,
141
141
# using the i8 representation.
142
142
local_value = tz_convert_utc_to_tzlocal(value, tz)
143
143
dt64_to_dtstruct(local_value, & dts)
144
- result[i] = func_create(value, dts, tz, freq)
144
+ result[i] = func_create(value, dts, tz, freq, fold )
145
145
else :
146
146
trans, deltas, typ = get_dst_info(tz)
147
147
@@ -155,7 +155,7 @@ def ints_to_pydatetime(const int64_t[:] arr, object tz=None, object freq=None,
155
155
else :
156
156
# Adjust datetime64 timestamp, recompute datetimestruct
157
157
dt64_to_dtstruct(value + delta, & dts)
158
- result[i] = func_create(value, dts, tz, freq)
158
+ result[i] = func_create(value, dts, tz, freq, fold )
159
159
160
160
elif typ == ' dateutil' :
161
161
# no zone-name change for dateutil tzs - dst etc
@@ -168,7 +168,7 @@ def ints_to_pydatetime(const int64_t[:] arr, object tz=None, object freq=None,
168
168
# Adjust datetime64 timestamp, recompute datetimestruct
169
169
pos = trans.searchsorted(value, side = ' right' ) - 1
170
170
dt64_to_dtstruct(value + deltas[pos], & dts)
171
- result[i] = func_create(value, dts, tz, freq)
171
+ result[i] = func_create(value, dts, tz, freq, fold )
172
172
else :
173
173
# pytz
174
174
for i in range (n):
@@ -182,7 +182,7 @@ def ints_to_pydatetime(const int64_t[:] arr, object tz=None, object freq=None,
182
182
new_tz = tz._tzinfos[tz._transition_info[pos]]
183
183
184
184
dt64_to_dtstruct(value + deltas[pos], & dts)
185
- result[i] = func_create(value, dts, new_tz, freq)
185
+ result[i] = func_create(value, dts, new_tz, freq, fold )
186
186
187
187
return result
188
188
0 commit comments