@@ -46,8 +46,6 @@ from datetime cimport (
4646 get_datetime64_unit,
4747 PANDAS_DATETIMEUNIT,
4848 _string_to_dts,
49- _pydatetime_to_dts,
50- _date_to_datetime64,
5149 npy_datetime,
5250 is_leapyear,
5351 dayofweek,
@@ -58,7 +56,8 @@ from datetime import time as datetime_time
5856
5957from tslibs.np_datetime cimport (check_dts_bounds,
6058 pandas_datetimestruct,
61- dt64_to_dtstruct, dtstruct_to_dt64)
59+ dt64_to_dtstruct, dtstruct_to_dt64,
60+ pydatetime_to_dt64, pydate_to_dt64)
6261from tslibs.np_datetime import OutOfBoundsDatetime
6362
6463from khash cimport (
@@ -1674,15 +1673,15 @@ cdef _TSObject convert_datetime_to_tsobject(datetime ts, object tz,
16741673 if (hasattr (tz, ' normalize' ) and
16751674 hasattr (ts.tzinfo, ' _utcoffset' )):
16761675 ts = tz.normalize(ts)
1677- obj.value = _pydatetime_to_dts (ts, & obj.dts)
1676+ obj.value = pydatetime_to_dt64 (ts, & obj.dts)
16781677 obj.tzinfo = ts.tzinfo
16791678 else :
16801679 # tzoffset
16811680 try :
16821681 tz = ts.astimezone(tz).tzinfo
16831682 except :
16841683 pass
1685- obj.value = _pydatetime_to_dts (ts, & obj.dts)
1684+ obj.value = pydatetime_to_dt64 (ts, & obj.dts)
16861685 ts_offset = get_utcoffset(ts.tzinfo, ts)
16871686 obj.value -= int (ts_offset.total_seconds() * 1e9 )
16881687 tz_offset = get_utcoffset(tz, ts)
@@ -1691,14 +1690,14 @@ cdef _TSObject convert_datetime_to_tsobject(datetime ts, object tz,
16911690 obj.tzinfo = tz
16921691 elif not is_utc(tz):
16931692 ts = _localize_pydatetime(ts, tz)
1694- obj.value = _pydatetime_to_dts (ts, & obj.dts)
1693+ obj.value = pydatetime_to_dt64 (ts, & obj.dts)
16951694 obj.tzinfo = ts.tzinfo
16961695 else :
16971696 # UTC
1698- obj.value = _pydatetime_to_dts (ts, & obj.dts)
1697+ obj.value = pydatetime_to_dt64 (ts, & obj.dts)
16991698 obj.tzinfo = pytz.utc
17001699 else :
1701- obj.value = _pydatetime_to_dts (ts, & obj.dts)
1700+ obj.value = pydatetime_to_dt64 (ts, & obj.dts)
17021701 obj.tzinfo = ts.tzinfo
17031702
17041703 if obj.tzinfo is not None and not is_utc(obj.tzinfo):
@@ -1851,7 +1850,7 @@ def datetime_to_datetime64(ndarray[object] values):
18511850 if inferred_tz is not None :
18521851 raise ValueError (' Cannot mix tz-aware with '
18531852 ' tz-naive values' )
1854- iresult[i] = _pydatetime_to_dts (val, & dts)
1853+ iresult[i] = pydatetime_to_dt64 (val, & dts)
18551854 check_dts_bounds(& dts)
18561855 else :
18571856 raise TypeError (' Unrecognized value type: %s ' % type (val))
@@ -2176,7 +2175,7 @@ cpdef array_to_datetime(ndarray[object] values, errors='raise',
21762175 ' be converted to datetime64 unless '
21772176 ' utc=True' )
21782177 else :
2179- iresult[i] = _pydatetime_to_dts (val, & dts)
2178+ iresult[i] = pydatetime_to_dt64 (val, & dts)
21802179 if is_timestamp(val):
21812180 iresult[i] += val.nanosecond
21822181 try :
@@ -2188,7 +2187,7 @@ cpdef array_to_datetime(ndarray[object] values, errors='raise',
21882187 raise
21892188
21902189 elif PyDate_Check(val):
2191- iresult[i] = _date_to_datetime64 (val, & dts)
2190+ iresult[i] = pydate_to_dt64 (val, & dts)
21922191 try :
21932192 check_dts_bounds(& dts)
21942193 seen_datetime = 1
@@ -2344,7 +2343,7 @@ cpdef array_to_datetime(ndarray[object] values, errors='raise',
23442343 try :
23452344 oresult[i] = parse_datetime_string(val, dayfirst = dayfirst,
23462345 yearfirst = yearfirst)
2347- _pydatetime_to_dts (oresult[i], & dts)
2346+ pydatetime_to_dt64 (oresult[i], & dts)
23482347 check_dts_bounds(& dts)
23492348 except Exception :
23502349 if is_raise:
0 commit comments