Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove sign if
  • Loading branch information
dontgoto committed Mar 25, 2024
commit b3c0199fd3af31cceb45278751d9be45d35d55ce
5 changes: 4 additions & 1 deletion pandas/_libs/src/vendored/numpy/datetime/np_datetime.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,8 +754,9 @@ void pandas_timedelta_to_timedeltastruct(npy_timedelta td,
const npy_int64 per_day = sec_per_day * per_sec;
npy_int64 ifrac = td;
const int sign = td < 0 ? -1 : 1;
const int uneven_in_seconds = td % per_sec != 0;
// put frac in seconds
if (sign < 0 && td % per_sec != 0)
if (sign < 0 && uneven_in_seconds)
td = td / per_sec - 1;
else
td = td / per_sec;
Expand All @@ -775,6 +776,8 @@ void pandas_timedelta_to_timedeltastruct(npy_timedelta td,
td -= out->days * sec_per_day;
}

out->days = sign * (out->days);

if (td >= sec_per_hour) {
out->hrs = (npy_int32)(td / sec_per_hour);
td %= sec_per_hour;
Expand Down