Skip to main content

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


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

If you're not sure about the file name format, learn more about wheel file names.

timedelta_isoformat-0.2.2.6-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file timedelta_isoformat-0.2.2.6-py3-none-any.whl.

File metadata

File hashes

Hashes for timedelta_isoformat-0.2.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 429b1f325cb2281f41d97c4dbd21a313b0e44ee7c2c0d68f879b4503d268ebaf
MD5 6761160ec87a8178adcb6244cac0bc6f
BLAKE2b-256 65b39d28f3af477a068833f468d55910692bc842a0783ebc0933ca734464b212

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page