@@ -33,7 +33,6 @@ cimport util
33
33
from cpython.datetime cimport PyDelta_Check, PyTZInfo_Check
34
34
# this is our datetime.pxd
35
35
from datetime cimport (
36
- pandas_datetimestruct,
37
36
pandas_datetime_to_datetimestruct,
38
37
pandas_datetimestruct_to_datetime,
39
38
days_per_month_table,
@@ -50,14 +49,15 @@ from datetime cimport (
50
49
PANDAS_FR_ns,
51
50
PyDateTime_Check, PyDate_Check,
52
51
PyDateTime_IMPORT,
53
- timedelta, datetime
54
- )
52
+ timedelta, datetime)
55
53
56
54
# stdlib datetime imports
57
55
from datetime import timedelta, datetime
58
56
from datetime import time as datetime_time
59
57
60
- from tslibs.np_datetime cimport check_dts_bounds
58
+ from tslibs.np_datetime cimport (check_dts_bounds,
59
+ pandas_datetimestruct,
60
+ dt64_to_dtstruct, dtstruct_to_dt64)
61
61
from tslibs.np_datetime import OutOfBoundsDatetime
62
62
63
63
from khash cimport (
@@ -149,17 +149,15 @@ def ints_to_pydatetime(ndarray[int64_t] arr, tz=None, freq=None, box=False):
149
149
if value == NPY_NAT:
150
150
result[i] = NaT
151
151
else :
152
- pandas_datetime_to_datetimestruct(
153
- value, PANDAS_FR_ns, & dts)
152
+ dt64_to_dtstruct(value, & dts)
154
153
result[i] = func_create(value, dts, tz, freq)
155
154
elif is_tzlocal(tz) or is_fixed_offset(tz):
156
155
for i in range (n):
157
156
value = arr[i]
158
157
if value == NPY_NAT:
159
158
result[i] = NaT
160
159
else :
161
- pandas_datetime_to_datetimestruct(
162
- value, PANDAS_FR_ns, & dts)
160
+ dt64_to_dtstruct(value, & dts)
163
161
dt = create_datetime_from_ts(value, dts, tz, freq)
164
162
dt = dt + tz.utcoffset(dt)
165
163
if box:
@@ -185,8 +183,7 @@ def ints_to_pydatetime(ndarray[int64_t] arr, tz=None, freq=None, box=False):
185
183
# represented in single object.
186
184
new_tz = tz
187
185
188
- pandas_datetime_to_datetimestruct(
189
- value + deltas[pos], PANDAS_FR_ns, & dts)
186
+ dt64_to_dtstruct(value + deltas[pos], & dts)
190
187
result[i] = func_create(value, dts, new_tz, freq)
191
188
else :
192
189
for i in range (n):
@@ -195,7 +192,7 @@ def ints_to_pydatetime(ndarray[int64_t] arr, tz=None, freq=None, box=False):
195
192
if value == NPY_NAT:
196
193
result[i] = NaT
197
194
else :
198
- pandas_datetime_to_datetimestruct (value, PANDAS_FR_ns , & dts)
195
+ dt64_to_dtstruct (value, & dts)
199
196
result[i] = func_create(value, dts, None , freq)
200
197
201
198
return result
@@ -698,7 +695,7 @@ class Timestamp(_Timestamp):
698
695
value += value - value_tz
699
696
700
697
# setup components
701
- pandas_datetime_to_datetimestruct (value, PANDAS_FR_ns , & dts)
698
+ dt64_to_dtstruct (value, & dts)
702
699
dts.ps = self .nanosecond * 1000
703
700
704
701
# replace
@@ -1811,7 +1808,7 @@ def _test_parse_iso8601(object ts):
1811
1808
obj = _TSObject()
1812
1809
1813
1810
_string_to_dts(ts, & obj.dts, & out_local, & out_tzoffset)
1814
- obj.value = pandas_datetimestruct_to_datetime(PANDAS_FR_ns, & obj.dts)
1811
+ obj.value = dtstruct_to_dt64( & obj.dts)
1815
1812
check_dts_bounds(& obj.dts)
1816
1813
if out_local == 1 :
1817
1814
obj.tzinfo = pytz.FixedOffset(out_tzoffset)
@@ -1984,7 +1981,7 @@ def format_array_from_datetime(ndarray[int64_t] values, object tz=None,
1984
1981
result[i] = na_rep
1985
1982
elif basic_format:
1986
1983
1987
- pandas_datetime_to_datetimestruct (val, PANDAS_FR_ns , & dts)
1984
+ dt64_to_dtstruct (val, & dts)
1988
1985
res = ' %d -%.2d -%.2d %.2d :%.2d :%.2d ' % (dts.year,
1989
1986
dts.month,
1990
1987
dts.day,
@@ -3792,7 +3789,7 @@ cdef inline int64_t _normalized_stamp(pandas_datetimestruct *dts) nogil:
3792
3789
dts.sec = 0
3793
3790
dts.us = 0
3794
3791
dts.ps = 0
3795
- return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, dts)
3792
+ return dtstruct_to_dt64( dts)
3796
3793
3797
3794
3798
3795
def dates_normalized (ndarray[int64_t] stamps , tz = None ):
@@ -3910,13 +3907,12 @@ def shift_months(int64_t[:] dtindex, int months, object day=None):
3910
3907
out[i] = NPY_NAT
3911
3908
continue
3912
3909
3913
- pandas_datetime_to_datetimestruct(dtindex[i],
3914
- PANDAS_FR_ns, & dts)
3910
+ dt64_to_dtstruct(dtindex[i], & dts)
3915
3911
dts.year = _year_add_months(dts, months)
3916
3912
dts.month = _month_add_months(dts, months)
3917
3913
3918
3914
dts.day = min (dts.day, days_in_month(dts))
3919
- out[i] = pandas_datetimestruct_to_datetime(PANDAS_FR_ns, & dts)
3915
+ out[i] = dtstruct_to_dt64( & dts)
3920
3916
elif day == ' start' :
3921
3917
roll_check = False
3922
3918
if months <= 0 :
@@ -3928,8 +3924,7 @@ def shift_months(int64_t[:] dtindex, int months, object day=None):
3928
3924
out[i] = NPY_NAT
3929
3925
continue
3930
3926
3931
- pandas_datetime_to_datetimestruct(dtindex[i],
3932
- PANDAS_FR_ns, & dts)
3927
+ dt64_to_dtstruct(dtindex[i], & dts)
3933
3928
months_to_roll = months
3934
3929
3935
3930
# offset semantics - if on the anchor point and going backwards
@@ -3941,7 +3936,7 @@ def shift_months(int64_t[:] dtindex, int months, object day=None):
3941
3936
dts.month = _month_add_months(dts, months_to_roll)
3942
3937
dts.day = 1
3943
3938
3944
- out[i] = pandas_datetimestruct_to_datetime(PANDAS_FR_ns, & dts)
3939
+ out[i] = dtstruct_to_dt64( & dts)
3945
3940
elif day == ' end' :
3946
3941
roll_check = False
3947
3942
if months > 0 :
@@ -3953,8 +3948,7 @@ def shift_months(int64_t[:] dtindex, int months, object day=None):
3953
3948
out[i] = NPY_NAT
3954
3949
continue
3955
3950
3956
- pandas_datetime_to_datetimestruct(dtindex[i],
3957
- PANDAS_FR_ns, & dts)
3951
+ dt64_to_dtstruct(dtindex[i], & dts)
3958
3952
months_to_roll = months
3959
3953
3960
3954
# similar semantics - when adding shift forward by one
@@ -3966,7 +3960,7 @@ def shift_months(int64_t[:] dtindex, int months, object day=None):
3966
3960
dts.month = _month_add_months(dts, months_to_roll)
3967
3961
3968
3962
dts.day = days_in_month(dts)
3969
- out[i] = pandas_datetimestruct_to_datetime(PANDAS_FR_ns, & dts)
3963
+ out[i] = dtstruct_to_dt64( & dts)
3970
3964
else :
3971
3965
raise ValueError (" day must be None, 'start' or 'end'" )
3972
3966
0 commit comments