Skip to content

fix(precisedelta): keep sign of negative timedeltas (#379) - #455

Open
artvepa80 wants to merge 1 commit into
python-humanize:mainfrom
artvepa80:fix-379-precisedelta-sign
Open

artvepa80 wants to merge 1 commit into
python-humanize:mainfrom
artvepa80:fix-379-precisedelta-sign

Conversation

@artvepa80

Copy link
Copy Markdown

Fixes #379

Changes proposed in this pull request:

  • precisedelta dropped the sign of negative timedeltas and negative numbers of seconds, so they rendered the same as the positive duration.
  • Remember the original sign before _date_and_delta() takes the absolute value, and prefix the formatted result with - when the input is negative.
  • Add regression tests for negative timedeltas, a negative number of seconds, and the positive and zero cases.

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