Supplemental ISO8601 duration format support for datetime.timedelta
Project description
The timedelta-isoformat library provides supplemental ISO 8601 duration support to the datetime.timedelta class.
The library is pure-Python, and does not depend upon regular expressions.
Functionality is provided in a subclass of datetime.timedelta that implements additional isoformat() and fromisoformat(duration_string) methods.
Usage
>>> from timedelta_isoformat import timedelta
>>> from datetime import datetime
>>>
>>> first = datetime(year=2022, month=10, day=2)
>>> second = datetime(year=2022, month=11, day=27, hour=14)
>>>
>>> td = timedelta(seconds=(second - first).total_seconds())
>>> td.isoformat()
'P56DT14H'
>>>
>>> first + timedelta.fromisoformat('P56DT14H')
datetime.datetime(2022, 11, 27, 14, 0)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for timedelta_isoformat-0.4.3.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 118fea6378111b467f34d099da83c6240722486c86efada40517344d4dfa1116 |
|
MD5 | b2647a19ceb47c18c22e03e8936eea69 |
|
BLAKE2b-256 | 54ba896fd9c133e9cc930cd0e53e4a8293c2d3c2afc0be8db191aa7e23dcf9ca |