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.

Author Erik Cederstrand
Recipients Erik Cederstrand
Date 2020-10-20.07:13:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1603178033.64.0.797359415965.issue42094@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-10-20 07:13:53Erik Cederstrandsetrecipients: + Erik Cederstrand
2020-10-20 07:13:53Erik Cederstrandsetmessageid: <1603178033.64.0.797359415965.issue42094@roundup.psfhosted.org>
2020-10-20 07:13:53Erik Cederstrandlinkissue42094 messages
2020-10-20 07:13:53Erik Cederstrandcreate