File tree 1 file changed +10
-7
lines changed
1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -332,13 +332,16 @@ timedelta-like}
332
332
# Shift the delta_idx by if the UTC offset of
333
333
# the target tz is greater than 0 and we're moving forward
334
334
# or vice versa
335
- first_delta = info.deltas[0 ]
336
- if (shift_forward or shift_delta > 0 ) and first_delta > 0 :
337
- delta_idx_offset = 1
338
- elif (shift_backward or shift_delta < 0 ) and first_delta < 0 :
339
- delta_idx_offset = 1
340
- else :
341
- delta_idx_offset = 0
335
+ # TODO: delta_idx_offset and info.deltas are needed for zoneinfo timezones,
336
+ # but are not applicable for all timezones. Setting the former to 0 and
337
+ # length checking the latter avoids UB, but this could use a larger refactor
338
+ delta_idx_offset = 0
339
+ if len (info.deltas):
340
+ first_delta = info.deltas[0 ]
341
+ if (shift_forward or shift_delta > 0 ) and first_delta > 0 :
342
+ delta_idx_offset = 1
343
+ elif (shift_backward or shift_delta < 0 ) and first_delta < 0 :
344
+ delta_idx_offset = 1
342
345
343
346
for i in range (n):
344
347
val = vals[i]
You can’t perform that action at this time.
0 commit comments