@@ -8,6 +8,7 @@ from cpython.datetime cimport (
8
8
datetime,
9
9
time,
10
10
timedelta,
11
+ tzinfo,
11
12
)
12
13
# import datetime C API
13
14
PyDateTime_IMPORT
@@ -77,9 +78,9 @@ from pandas._libs.missing cimport checknull_with_nat_and_na
77
78
cdef inline object create_datetime_from_ts(
78
79
int64_t value,
79
80
npy_datetimestruct dts,
80
- object tz,
81
+ tzinfo tz,
81
82
object freq,
82
- bint fold
83
+ bint fold,
83
84
):
84
85
"""
85
86
Convenience routine to construct a datetime.datetime from its parts.
@@ -92,7 +93,7 @@ cdef inline object create_datetime_from_ts(
92
93
cdef inline object create_date_from_ts(
93
94
int64_t value,
94
95
npy_datetimestruct dts,
95
- object tz,
96
+ tzinfo tz,
96
97
object freq,
97
98
bint fold
98
99
):
@@ -106,7 +107,7 @@ cdef inline object create_date_from_ts(
106
107
cdef inline object create_time_from_ts(
107
108
int64_t value,
108
109
npy_datetimestruct dts,
109
- object tz,
110
+ tzinfo tz,
110
111
object freq,
111
112
bint fold
112
113
):
@@ -120,7 +121,7 @@ cdef inline object create_time_from_ts(
120
121
@ cython.boundscheck (False )
121
122
def ints_to_pydatetime (
122
123
const int64_t[:] arr ,
123
- object tz = None ,
124
+ tzinfo tz = None ,
124
125
object freq = None ,
125
126
bint fold = False ,
126
127
str box = " datetime"
@@ -162,7 +163,7 @@ def ints_to_pydatetime(
162
163
str typ
163
164
int64_t value, delta, local_value
164
165
ndarray[object ] result = np.empty(n, dtype = object )
165
- object (* func_create)(int64_t, npy_datetimestruct, object , object , bint)
166
+ object (* func_create)(int64_t, npy_datetimestruct, tzinfo , object , bint)
166
167
167
168
if box == " date" :
168
169
assert (tz is None ), " tz should be None when converting to date"
@@ -178,7 +179,9 @@ def ints_to_pydatetime(
178
179
elif box == " datetime" :
179
180
func_create = create_datetime_from_ts
180
181
else :
181
- raise ValueError (" box must be one of 'datetime', 'date', 'time' or 'timestamp'" )
182
+ raise ValueError (
183
+ " box must be one of 'datetime', 'date', 'time' or 'timestamp'"
184
+ )
182
185
183
186
if is_utc(tz) or tz is None :
184
187
for i in range (n):
0 commit comments