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
>>>
>>> epoch = datetime(year=2022, month=10, day=2)
>>> now = datetime.utcnow()
>>>
>>> td = timedelta(seconds=(now - epoch).total_seconds())
>>> td.isoformat()
'P55DT17H28M51S'
>>>
>>> epoch + timedelta.fromisoformat('P55DT17H28M51S')
datetime.datetime(2022, 11, 26, 17, 28, 51)

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.1.0.2-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: timedelta_isoformat-0.1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

File hashes

Hashes for timedelta_isoformat-0.1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 94789cbbd0474f856742ba877befaceb7a11ec3cdf225f422d4db4d7792d74ce
MD5 3b4f06bfea55e727f77b2f75857a9f23
BLAKE2b-256 a95d2ead3c3bb2a3f4140dc9864e6be59275c370a6acec2cb10f39d46a3310a3

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