@@ -16,7 +16,7 @@ cimport numpy as cnp
16
16
from numpy cimport ndarray, int64_t, uint8_t, intp_t
17
17
cnp.import_array()
18
18
19
- from pandas._libs.tslibs.ccalendar import DAY_SECONDS, HOUR_SECONDS
19
+ from pandas._libs.tslibs.ccalendar cimport DAY_NANOS, HOUR_NANOS
20
20
from pandas._libs.tslibs.nattype cimport NPY_NAT
21
21
from pandas._libs.tslibs.np_datetime cimport (
22
22
npy_datetimestruct, dt64_to_dtstruct)
@@ -71,7 +71,7 @@ timedelta-like}
71
71
int64_t * tdata
72
72
int64_t v, left, right, val, v_left, v_right, new_local, remaining_mins
73
73
int64_t first_delta
74
- int64_t HOURS_NS = HOUR_SECONDS * 1000000000 , shift_delta = 0
74
+ int64_t shift_delta = 0
75
75
ndarray[int64_t] trans, result, result_a, result_b, dst_hours, delta
76
76
ndarray trans_idx, grp, a_idx, b_idx, one_diff
77
77
npy_datetimestruct dts
@@ -142,10 +142,10 @@ timedelta-like}
142
142
result_b[:] = NPY_NAT
143
143
144
144
idx_shifted_left = (np.maximum(0 , trans.searchsorted(
145
- vals - DAY_SECONDS * 1000000000 , side = ' right' ) - 1 )).astype(np.int64)
145
+ vals - DAY_NANOS , side = ' right' ) - 1 )).astype(np.int64)
146
146
147
147
idx_shifted_right = (np.maximum(0 , trans.searchsorted(
148
- vals + DAY_SECONDS * 1000000000 , side = ' right' ) - 1 )).astype(np.int64)
148
+ vals + DAY_NANOS , side = ' right' ) - 1 )).astype(np.int64)
149
149
150
150
for i in range (n):
151
151
val = vals[i]
@@ -240,18 +240,18 @@ timedelta-like}
240
240
# Handle nonexistent times
241
241
if shift_forward or shift_backward or shift_delta != 0 :
242
242
# Shift the nonexistent time to the closest existing time
243
- remaining_mins = val % HOURS_NS
243
+ remaining_mins = val % HOUR_NANOS
244
244
if shift_delta != 0 :
245
245
# Validate that we don't relocalize on another nonexistent
246
246
# time
247
- if - 1 < shift_delta + remaining_mins < HOURS_NS :
247
+ if - 1 < shift_delta + remaining_mins < HOUR_NANOS :
248
248
raise ValueError (
249
249
f" The provided timedelta will relocalize on a "
250
250
f" nonexistent time: {nonexistent}"
251
251
)
252
252
new_local = val + shift_delta
253
253
elif shift_forward:
254
- new_local = val + (HOURS_NS - remaining_mins)
254
+ new_local = val + (HOUR_NANOS - remaining_mins)
255
255
else :
256
256
# Subtract 1 since the beginning hour is _inclusive_ of
257
257
# nonexistent times
0 commit comments