Message379091
Python 3.7 gained support for parsing ISO 8601 formatted time, date and datetime strings via the fromisoformat() methods. Python has seen improved support for ISO 8601 in general; ISO calendar format codes were added in Python 3.6, and fromisocalendar() was added in Python 3.8.
ISO 8601 also has a standard for durations: https://en.wikipedia.org/wiki/ISO_8601#Durations
For consistency with the other objects in the datetime module, I suggest adding isoformat()/fromisoformat() methods for datetime.timedelta that implement ISO 8601 durations.
ISO 8601 durations support years and months that are not valid timedelta arguments because they are non-precise durations. I suggest throwing an exception if the conversion to or from timedelta cannot be done safely.
https://pypi.org/project/isodate/ implements a parse_duration() method that could be used for inspiration. |
|
Date |
User |
Action |
Args |
2020-10-20 07:13:53 | Erik Cederstrand | set | recipients:
+ Erik Cederstrand |
2020-10-20 07:13:53 | Erik Cederstrand | set | messageid: <1603178033.64.0.797359415965.issue42094@roundup.psfhosted.org> |
2020-10-20 07:13:53 | Erik Cederstrand | link | issue42094 messages |
2020-10-20 07:13:53 | Erik Cederstrand | create | |
|