@@ -46,8 +46,6 @@ from datetime cimport (
46
46
get_datetime64_unit,
47
47
PANDAS_DATETIMEUNIT,
48
48
_string_to_dts,
49
- _pydatetime_to_dts,
50
- _date_to_datetime64,
51
49
npy_datetime,
52
50
is_leapyear,
53
51
dayofweek,
@@ -58,7 +56,8 @@ from datetime import time as datetime_time
58
56
59
57
from tslibs.np_datetime cimport (check_dts_bounds,
60
58
pandas_datetimestruct,
61
- dt64_to_dtstruct, dtstruct_to_dt64)
59
+ dt64_to_dtstruct, dtstruct_to_dt64,
60
+ pydatetime_to_dt64, pydate_to_dt64)
62
61
from tslibs.np_datetime import OutOfBoundsDatetime
63
62
64
63
from khash cimport (
@@ -1674,15 +1673,15 @@ cdef _TSObject convert_datetime_to_tsobject(datetime ts, object tz,
1674
1673
if (hasattr (tz, ' normalize' ) and
1675
1674
hasattr (ts.tzinfo, ' _utcoffset' )):
1676
1675
ts = tz.normalize(ts)
1677
- obj.value = _pydatetime_to_dts (ts, & obj.dts)
1676
+ obj.value = pydatetime_to_dt64 (ts, & obj.dts)
1678
1677
obj.tzinfo = ts.tzinfo
1679
1678
else :
1680
1679
# tzoffset
1681
1680
try :
1682
1681
tz = ts.astimezone(tz).tzinfo
1683
1682
except :
1684
1683
pass
1685
- obj.value = _pydatetime_to_dts (ts, & obj.dts)
1684
+ obj.value = pydatetime_to_dt64 (ts, & obj.dts)
1686
1685
ts_offset = get_utcoffset(ts.tzinfo, ts)
1687
1686
obj.value -= int (ts_offset.total_seconds() * 1e9 )
1688
1687
tz_offset = get_utcoffset(tz, ts)
@@ -1691,14 +1690,14 @@ cdef _TSObject convert_datetime_to_tsobject(datetime ts, object tz,
1691
1690
obj.tzinfo = tz
1692
1691
elif not is_utc(tz):
1693
1692
ts = _localize_pydatetime(ts, tz)
1694
- obj.value = _pydatetime_to_dts (ts, & obj.dts)
1693
+ obj.value = pydatetime_to_dt64 (ts, & obj.dts)
1695
1694
obj.tzinfo = ts.tzinfo
1696
1695
else :
1697
1696
# UTC
1698
- obj.value = _pydatetime_to_dts (ts, & obj.dts)
1697
+ obj.value = pydatetime_to_dt64 (ts, & obj.dts)
1699
1698
obj.tzinfo = pytz.utc
1700
1699
else :
1701
- obj.value = _pydatetime_to_dts (ts, & obj.dts)
1700
+ obj.value = pydatetime_to_dt64 (ts, & obj.dts)
1702
1701
obj.tzinfo = ts.tzinfo
1703
1702
1704
1703
if obj.tzinfo is not None and not is_utc(obj.tzinfo):
@@ -1851,7 +1850,7 @@ def datetime_to_datetime64(ndarray[object] values):
1851
1850
if inferred_tz is not None :
1852
1851
raise ValueError (' Cannot mix tz-aware with '
1853
1852
' tz-naive values' )
1854
- iresult[i] = _pydatetime_to_dts (val, & dts)
1853
+ iresult[i] = pydatetime_to_dt64 (val, & dts)
1855
1854
check_dts_bounds(& dts)
1856
1855
else :
1857
1856
raise TypeError (' Unrecognized value type: %s ' % type (val))
@@ -2176,7 +2175,7 @@ cpdef array_to_datetime(ndarray[object] values, errors='raise',
2176
2175
' be converted to datetime64 unless '
2177
2176
' utc=True' )
2178
2177
else :
2179
- iresult[i] = _pydatetime_to_dts (val, & dts)
2178
+ iresult[i] = pydatetime_to_dt64 (val, & dts)
2180
2179
if is_timestamp(val):
2181
2180
iresult[i] += val.nanosecond
2182
2181
try :
@@ -2188,7 +2187,7 @@ cpdef array_to_datetime(ndarray[object] values, errors='raise',
2188
2187
raise
2189
2188
2190
2189
elif PyDate_Check(val):
2191
- iresult[i] = _date_to_datetime64 (val, & dts)
2190
+ iresult[i] = pydate_to_dt64 (val, & dts)
2192
2191
try :
2193
2192
check_dts_bounds(& dts)
2194
2193
seen_datetime = 1
@@ -2344,7 +2343,7 @@ cpdef array_to_datetime(ndarray[object] values, errors='raise',
2344
2343
try :
2345
2344
oresult[i] = parse_datetime_string(val, dayfirst = dayfirst,
2346
2345
yearfirst = yearfirst)
2347
- _pydatetime_to_dts (oresult[i], & dts)
2346
+ pydatetime_to_dt64 (oresult[i], & dts)
2348
2347
check_dts_bounds(& dts)
2349
2348
except Exception :
2350
2349
if is_raise:
0 commit comments