@@ -37,7 +37,6 @@ from pandas._libs.tslibs.np_datetime cimport (
37
37
NPY_DATETIMEUNIT,
38
38
NPY_FR_ns,
39
39
check_dts_bounds,
40
- dtstruct_to_dt64,
41
40
get_datetime64_unit,
42
41
get_datetime64_value,
43
42
get_implementation_bounds,
@@ -171,7 +170,7 @@ cpdef inline (int64_t, int) precision_from_unit(str unit):
171
170
return m, p
172
171
173
172
174
- cdef inline int64_t get_datetime64_nanos(object val) except ? - 1 :
173
+ cdef inline int64_t get_datetime64_nanos(object val, NPY_DATETIMEUNIT reso ) except ? - 1 :
175
174
"""
176
175
Extract the value and unit from a np.datetime64 object, then convert the
177
176
value to nanoseconds if necessary.
@@ -187,10 +186,10 @@ cdef inline int64_t get_datetime64_nanos(object val) except? -1:
187
186
188
187
unit = get_datetime64_unit(val)
189
188
190
- if unit != NPY_FR_ns :
189
+ if unit != reso :
191
190
pandas_datetime_to_datetimestruct(ival, unit, & dts)
192
- check_dts_bounds(& dts)
193
- ival = dtstruct_to_dt64( & dts)
191
+ check_dts_bounds(& dts, reso )
192
+ ival = npy_datetimestruct_to_datetime(reso, & dts)
194
193
195
194
return ival
196
195
@@ -238,7 +237,7 @@ cdef _TSObject convert_to_tsobject(object ts, tzinfo tz, str unit,
238
237
if ts is None or ts is NaT:
239
238
obj.value = NPY_NAT
240
239
elif is_datetime64_object(ts):
241
- obj.value = get_datetime64_nanos(ts)
240
+ obj.value = get_datetime64_nanos(ts, NPY_FR_ns )
242
241
if obj.value != NPY_NAT:
243
242
pandas_datetime_to_datetimestruct(obj.value, NPY_FR_ns, & obj.dts)
244
243
elif is_integer_object(ts):
@@ -403,7 +402,7 @@ cdef _TSObject _create_tsobject_tz_using_offset(npy_datetimestruct dts,
403
402
datetime dt
404
403
Py_ssize_t pos
405
404
406
- value = dtstruct_to_dt64( & dts)
405
+ value = npy_datetimestruct_to_datetime(NPY_FR_ns, & dts)
407
406
obj.dts = dts
408
407
obj.tzinfo = pytz.FixedOffset(tzoffset)
409
408
obj.value = tz_localize_to_utc_single(value, obj.tzinfo)
@@ -490,12 +489,12 @@ cdef _TSObject _convert_str_to_tsobject(object ts, tzinfo tz, str unit,
490
489
)
491
490
if not string_to_dts_failed:
492
491
try :
493
- check_dts_bounds(& dts)
492
+ check_dts_bounds(& dts, NPY_FR_ns )
494
493
if out_local == 1 :
495
494
return _create_tsobject_tz_using_offset(dts,
496
495
out_tzoffset, tz)
497
496
else :
498
- ival = dtstruct_to_dt64( & dts)
497
+ ival = npy_datetimestruct_to_datetime(NPY_FR_ns, & dts)
499
498
if tz is not None :
500
499
# shift for _localize_tso
501
500
ival = tz_localize_to_utc_single(ival, tz,
0 commit comments