Skip to content

Commit eb6058c

Browse files
jbrockmendelyehoshuadimarsky
authored andcommitted
REF: remove dtstruct_to_dt64 (pandas-dev#47492)
1 parent 428d442 commit eb6058c

File tree

5 files changed

+5
-18
lines changed

5 files changed

+5
-18
lines changed

pandas/_libs/tslibs/conversion.pyx

+3-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ from pandas._libs.tslibs.np_datetime cimport (
4040
NPY_FR_ns,
4141
astype_overflowsafe,
4242
check_dts_bounds,
43-
dt64_to_dtstruct,
4443
dtstruct_to_dt64,
4544
get_datetime64_unit,
4645
get_datetime64_value,
@@ -248,7 +247,7 @@ cdef _TSObject convert_to_tsobject(object ts, tzinfo tz, str unit,
248247
elif is_datetime64_object(ts):
249248
obj.value = get_datetime64_nanos(ts)
250249
if obj.value != NPY_NAT:
251-
dt64_to_dtstruct(obj.value, &obj.dts)
250+
pandas_datetime_to_datetimestruct(obj.value, NPY_FR_ns, &obj.dts)
252251
elif is_integer_object(ts):
253252
try:
254253
ts = <int64_t>ts
@@ -266,7 +265,7 @@ cdef _TSObject convert_to_tsobject(object ts, tzinfo tz, str unit,
266265

267266
ts = ts * cast_from_unit(None, unit)
268267
obj.value = ts
269-
dt64_to_dtstruct(ts, &obj.dts)
268+
pandas_datetime_to_datetimestruct(ts, NPY_FR_ns, &obj.dts)
270269
elif is_float_object(ts):
271270
if ts != ts or ts == NPY_NAT:
272271
obj.value = NPY_NAT
@@ -289,7 +288,7 @@ cdef _TSObject convert_to_tsobject(object ts, tzinfo tz, str unit,
289288

290289
ts = cast_from_unit(ts, unit)
291290
obj.value = ts
292-
dt64_to_dtstruct(ts, &obj.dts)
291+
pandas_datetime_to_datetimestruct(ts, NPY_FR_ns, &obj.dts)
293292
elif PyDateTime_Check(ts):
294293
return convert_datetime_to_tsobject(ts, tz, nanos)
295294
elif PyDate_Check(ts):

pandas/_libs/tslibs/np_datetime.pxd

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ cdef bint cmp_scalar(int64_t lhs, int64_t rhs, int op) except -1
7676
cdef check_dts_bounds(npy_datetimestruct *dts, NPY_DATETIMEUNIT unit=?)
7777

7878
cdef int64_t dtstruct_to_dt64(npy_datetimestruct* dts) nogil
79-
cdef void dt64_to_dtstruct(int64_t dt64, npy_datetimestruct* out) nogil
8079

8180
cdef int64_t pydatetime_to_dt64(datetime val, npy_datetimestruct *dts)
8281
cdef void pydatetime_to_dtstruct(datetime dt, npy_datetimestruct *dts)

pandas/_libs/tslibs/np_datetime.pyx

-8
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,6 @@ cdef inline int64_t dtstruct_to_dt64(npy_datetimestruct* dts) nogil:
217217
return npy_datetimestruct_to_datetime(NPY_FR_ns, dts)
218218

219219

220-
cdef inline void dt64_to_dtstruct(int64_t dt64,
221-
npy_datetimestruct* out) nogil:
222-
"""Convenience function to call pandas_datetime_to_datetimestruct
223-
with the by-far-most-common frequency NPY_FR_ns"""
224-
pandas_datetime_to_datetimestruct(dt64, NPY_FR_ns, out)
225-
return
226-
227-
228220
# just exposed for testing at the moment
229221
def py_td64_to_tdstruct(int64_t td64, NPY_DATETIMEUNIT unit):
230222
cdef:

pandas/_libs/tslibs/period.pyx

+2-4
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ from pandas._libs.tslibs.np_datetime cimport (
4949
NPY_FR_us,
5050
astype_overflowsafe,
5151
check_dts_bounds,
52-
dt64_to_dtstruct,
53-
dtstruct_to_dt64,
5452
get_timedelta64_value,
5553
npy_datetimestruct,
5654
npy_datetimestruct_to_datetime,
@@ -813,7 +811,7 @@ cdef void get_date_info(int64_t ordinal, int freq, npy_datetimestruct *dts) nogi
813811

814812
pandas_datetime_to_datetimestruct(unix_date, NPY_FR_D, dts)
815813

816-
dt64_to_dtstruct(nanos, &dts2)
814+
pandas_datetime_to_datetimestruct(nanos, NPY_DATETIMEUNIT.NPY_FR_ns, &dts2)
817815
dts.hour = dts2.hour
818816
dts.min = dts2.min
819817
dts.sec = dts2.sec
@@ -1149,7 +1147,7 @@ cdef int64_t period_ordinal_to_dt64(int64_t ordinal, int freq) except? -1:
11491147
get_date_info(ordinal, freq, &dts)
11501148

11511149
check_dts_bounds(&dts)
1152-
return dtstruct_to_dt64(&dts)
1150+
return npy_datetimestruct_to_datetime(NPY_DATETIMEUNIT.NPY_FR_ns, &dts)
11531151

11541152

11551153
cdef str period_format(int64_t value, int freq, object fmt=None):

pandas/_libs/tslibs/vectorized.pyx

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ from .nattype cimport (
3030
from .np_datetime cimport (
3131
NPY_DATETIMEUNIT,
3232
NPY_FR_ns,
33-
dt64_to_dtstruct,
3433
npy_datetimestruct,
3534
pandas_datetime_to_datetimestruct,
3635
)

0 commit comments

Comments
 (0)