Skip to content

fix precisedelta dropping sign of negative timedeltas (fixes #379) - #395

Open
aDragon0707 wants to merge 2 commits into
python-humanize:mainfrom
aDragon0707:fix-379
Open

fix precisedelta dropping sign of negative timedeltas (fixes #379)#395
aDragon0707 wants to merge 2 commits into
python-humanize:mainfrom
aDragon0707:fix-379

Conversation

@aDragon0707

Copy link
Copy Markdown

Fixes #379.

precisedelta() silently dropped the sign of negative timedeltas — the output was byte-identical to the positive counterpart (1 hour, 1 minute and 1 second for both -3661 and +3661 seconds).

  • Detect a negative value before _date_and_delta, then prefix - on the rendered result.
  • Zero stays 0 seconds (no -0).
  • Positive inputs are unchanged.

Regression test added (test_precisedelta_negative): seconds, positive control, and minimum_unit="minutes".

tests/test_time.py → 388 passed, 0 failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

precisedelta() silently drops the sign of negative timedeltas

1 participant