Skip to main content

ISO 8601 duration parser

Reason this release was yanked:

potential license violation

Project description

timedelta-iso8601

timedelta-iso8601 is a pure-Python implementation of ISO 8601 duration parsing that does not rely on regular expressions.

Functionality is provided in a subclass of datetime.timedelta that implements additional isoformat() and fromisoformat(duration_string) methods.

Usage

>>> from timedelta import timedelta
>>> from datetime import datetime
>>>
>>> millenium = datetime(year=2000, month=1, day=1)
>>> now = datetime.utcnow()
>>>
>>> td = timedelta(seconds=(now - millenium).total_seconds())
>>> td.isoformat()
'P8310DT16H21M3S'
>>>
>>> millenium + timedelta.fromisoformat('P8310DT16H21M3S')
datetime.datetime(2022, 10, 2, 16, 21, 3)

Tests

To run the timedelta-iso8601 test suite:

$ python -m unittest

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

timedelta_iso8601-0.0.1-py3-none-any.whl (14.2 kB view hashes)

Uploaded Python 3

Supported by

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