diff --git a/pandas/_libs/tslibs/conversion.pyx b/pandas/_libs/tslibs/conversion.pyx index fb77e2b5f3a0c..00e2c8b8b6be6 100644 --- a/pandas/_libs/tslibs/conversion.pyx +++ b/pandas/_libs/tslibs/conversion.pyx @@ -40,7 +40,6 @@ from pandas._libs.tslibs.np_datetime cimport ( NPY_FR_ns, astype_overflowsafe, check_dts_bounds, - dt64_to_dtstruct, dtstruct_to_dt64, get_datetime64_unit, get_datetime64_value, @@ -248,7 +247,7 @@ cdef _TSObject convert_to_tsobject(object ts, tzinfo tz, str unit, elif is_datetime64_object(ts): obj.value = get_datetime64_nanos(ts) if obj.value != NPY_NAT: - dt64_to_dtstruct(obj.value, &obj.dts) + pandas_datetime_to_datetimestruct(obj.value, NPY_FR_ns, &obj.dts) elif is_integer_object(ts): try: ts = ts @@ -266,7 +265,7 @@ cdef _TSObject convert_to_tsobject(object ts, tzinfo tz, str unit, ts = ts * cast_from_unit(None, unit) obj.value = ts - dt64_to_dtstruct(ts, &obj.dts) + pandas_datetime_to_datetimestruct(ts, NPY_FR_ns, &obj.dts) elif is_float_object(ts): if ts != ts or ts == NPY_NAT: obj.value = NPY_NAT @@ -289,7 +288,7 @@ cdef _TSObject convert_to_tsobject(object ts, tzinfo tz, str unit, ts = cast_from_unit(ts, unit) obj.value = ts - dt64_to_dtstruct(ts, &obj.dts) + pandas_datetime_to_datetimestruct(ts, NPY_FR_ns, &obj.dts) elif PyDateTime_Check(ts): return convert_datetime_to_tsobject(ts, tz, nanos) elif PyDate_Check(ts): diff --git a/pandas/_libs/tslibs/np_datetime.pxd b/pandas/_libs/tslibs/np_datetime.pxd index 2f775912da141..290483a741fe7 100644 --- a/pandas/_libs/tslibs/np_datetime.pxd +++ b/pandas/_libs/tslibs/np_datetime.pxd @@ -76,7 +76,6 @@ cdef bint cmp_scalar(int64_t lhs, int64_t rhs, int op) except -1 cdef check_dts_bounds(npy_datetimestruct *dts, NPY_DATETIMEUNIT unit=?) cdef int64_t dtstruct_to_dt64(npy_datetimestruct* dts) nogil -cdef void dt64_to_dtstruct(int64_t dt64, npy_datetimestruct* out) nogil cdef int64_t pydatetime_to_dt64(datetime val, npy_datetimestruct *dts) cdef void pydatetime_to_dtstruct(datetime dt, npy_datetimestruct *dts) diff --git a/pandas/_libs/tslibs/np_datetime.pyx b/pandas/_libs/tslibs/np_datetime.pyx index 24ba329120a51..1aab5dcd6f70b 100644 --- a/pandas/_libs/tslibs/np_datetime.pyx +++ b/pandas/_libs/tslibs/np_datetime.pyx @@ -217,14 +217,6 @@ cdef inline int64_t dtstruct_to_dt64(npy_datetimestruct* dts) nogil: return npy_datetimestruct_to_datetime(NPY_FR_ns, dts) -cdef inline void dt64_to_dtstruct(int64_t dt64, - npy_datetimestruct* out) nogil: - """Convenience function to call pandas_datetime_to_datetimestruct - with the by-far-most-common frequency NPY_FR_ns""" - pandas_datetime_to_datetimestruct(dt64, NPY_FR_ns, out) - return - - # just exposed for testing at the moment def py_td64_to_tdstruct(int64_t td64, NPY_DATETIMEUNIT unit): cdef: diff --git a/pandas/_libs/tslibs/period.pyx b/pandas/_libs/tslibs/period.pyx index 0fa85f54944eb..e187df6d6f627 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -49,8 +49,6 @@ from pandas._libs.tslibs.np_datetime cimport ( NPY_FR_us, astype_overflowsafe, check_dts_bounds, - dt64_to_dtstruct, - dtstruct_to_dt64, get_timedelta64_value, npy_datetimestruct, npy_datetimestruct_to_datetime, @@ -813,7 +811,7 @@ cdef void get_date_info(int64_t ordinal, int freq, npy_datetimestruct *dts) nogi pandas_datetime_to_datetimestruct(unix_date, NPY_FR_D, dts) - dt64_to_dtstruct(nanos, &dts2) + pandas_datetime_to_datetimestruct(nanos, NPY_DATETIMEUNIT.NPY_FR_ns, &dts2) dts.hour = dts2.hour dts.min = dts2.min dts.sec = dts2.sec @@ -1149,7 +1147,7 @@ cdef int64_t period_ordinal_to_dt64(int64_t ordinal, int freq) except? -1: get_date_info(ordinal, freq, &dts) check_dts_bounds(&dts) - return dtstruct_to_dt64(&dts) + return npy_datetimestruct_to_datetime(NPY_DATETIMEUNIT.NPY_FR_ns, &dts) cdef str period_format(int64_t value, int freq, object fmt=None): diff --git a/pandas/_libs/tslibs/vectorized.pyx b/pandas/_libs/tslibs/vectorized.pyx index 598127b0eae7c..b63b4cf1df66b 100644 --- a/pandas/_libs/tslibs/vectorized.pyx +++ b/pandas/_libs/tslibs/vectorized.pyx @@ -30,7 +30,6 @@ from .nattype cimport ( from .np_datetime cimport ( NPY_DATETIMEUNIT, NPY_FR_ns, - dt64_to_dtstruct, npy_datetimestruct, pandas_datetime_to_datetimestruct, )