[issue41254] Add to/from string methods to datetime.timedelta

Martin Panter report at bugs.python.org
Thu Jul 9 09:02:49 EDT 2020


Martin Panter <vadmium+py at gmail.com> added the comment:

I don't know how much support this will get since there is already a str(timedelta) operation defined with a different format. But I don't like that format much. The day[s] part is too verbose, the H:MM:SS part could too easily be interpreted as D:HH:MM, and the result for negative deltas is horrible (-43 days, 23:59:55; see Issue 38701).

My favourite format for a duration is usually the HTML 5 format like

1w 0d 12h 0m 27s

Another option is ISO 8601 format:

P1W0DT12H0M27S

But both of these standards only go down to the seconds unit, so 50 ms has to be 0.05s or PT0.05S.

----------
nosy: +martin.panter

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41254>
_______________________________________


More information about the Python-bugs-list mailing list