This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: datetime.timedelta string representation is ambiguous
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: belopolsky, lig, p-ganssle
Priority: normal Keywords:

Created on 2019-11-05 15:48 by lig, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg356041 - (view) Author: Serge Matveenko (lig) * Date: 2019-11-05 15:48
Negative `timedelta` string representation is ambiguous.

```
>>> from datetime import datetime, timedelta
>>> d2 = datetime.now()
>>> d1 = d2 - timedelta(days=42, seconds=5)
>>> str(d2 - d1)
'42 days, 0:00:05'
>>> str(d1 - d2)
'-43 days, 23:59:55'
```

I would expect `str(d1 - d2)` to be one of the following:
* '-42 days, 0:00:05'
* '-(42 days, 0:00:05)'
* '- 42 days, 0:00:05'
msg368832 - (view) Author: Serge Matveenko (lig) * Date: 2020-05-14 11:51
I would be happy to submit a PR if there would be an agreement on the format.
History
Date User Action Args
2022-04-11 14:59:22adminsetgithub: 82882
2020-09-14 14:15:53ligsetstatus: open -> closed
stage: resolved
2020-05-14 11:51:51ligsetmessages: + msg368832
2019-11-05 16:59:46xtreaksetnosy: + belopolsky, p-ganssle
2019-11-05 15:48:39ligcreate