Why can a negative duration appear as negative days plus positive seconds?
timedelta normalizes its components so seconds stays within a day and days may carry the sign.
Python example and interpretation
An offset one second early is represented by minus one day and 86399 seconds. Apply absolute value to the full duration when computing error magnitude.
from datetime import timedelta
d=timedelta(seconds=-1)
[d.days,d.seconds,d.total_seconds()]Result [-1, 86399, -1.0]
中文
负的时间差为何显示为负一天加正的秒数?
timedelta 会把字段规范化,使 seconds 部分落在一天之内,符号可由 days 承担。
Python 算例与适用条件
提前一秒的偏移量可表示为 −1 天和 86399 秒。取绝对值前应处理整个时间差,不能只查看 seconds。
from datetime import timedelta
d=timedelta(seconds=-1)
[d.days,d.seconds,d.total_seconds()]结果 [-1, 86399, -1.0]