Skip to main content

Utilities for parsing ISO 8601 times, dates, datetimes, intervals, and durations

Project description

https://img.shields.io/pypi/v/iso8601utils.svg https://travis-ci.org/silverfernsys/iso8601utils.svg?branch=master https://codecov.io/gh/silverfernsys/iso8601utils/branch/master/graph/badge.svg https://img.shields.io/pypi/l/iso8601utils.svg https://img.shields.io/pypi/status/iso8601utils.svg https://img.shields.io/pypi/implementation/iso8601utils.svg https://img.shields.io/pypi/pyversions/iso8601utils.svg https://img.shields.io/pypi/format/iso8601utils.svg https://img.shields.io/librariesio/github/silverfernsys/iso8601utils.svg

iso8601utils

A set of utilities for parsing and validating ISO 8601 dates, times, durations, and intervals that also conform to the rfc3339 recommendations.

>>> from iso8601utils import parsers
>>> parsers.interval('2016-08-01T23:10:59.111Z/2016-08-08T00:13:23.001Z')
Interval(repeat=0, start=datetime.datetime(2016, 8, 1, 23, 10, 59, 111),
end=datetime.datetime(2016, 8, 8, 0, 13, 23, 1),
delta=Duration(timedelta=datetime.timedelta(6, 3743, 999890), monthdelta=MonthDelta(0)))

>>> parsers.interval('2002-08-15T16:20:05.100+08:10/2002-10-12T17:05:25.020-01:40')
Interval(repeat=0, start=datetime.datetime(2002, 8, 15, 16, 20, 5, 100, tzinfo=<TimezoneInfo(+8:10)>),
end=datetime.datetime(2002, 10, 12, 17, 5, 25, 20, tzinfo=<TimezoneInfo(-1:40)>),
delta=Duration(timedelta=datetime.timedelta(-3, 38119, 999920), monthdelta=MonthDelta(2)))

>>> parsers.duration('P3Y6M4DT12H30M5S')
Duration(timedelta=datetime.timedelta(4, 45005), monthdelta=MonthDelta(42))

>>> parsers.time('13:15+05:10')
datetime.time(13, 15, tzinfo=<TimezoneInfo(+5:10)>)

>>> parsers.date('1981-04-05')
datetime.date(1981, 4, 5)

>>> parsers.datetime('2007-08-09T12:30-02:00')
datetime.datetime(2007, 8, 9, 12, 30, tzinfo=<TimezoneInfo(-2:0)>)

>>> parsers.date('1981-095')
datetime.date(1981, 4, 5)

>>> parsers.date('2016-W43-1')
datetime.date(2016, 10, 24)

>>> from iso8601utils import validators
>>> validators.interval('1999-12-31T16:00:00.000+04:00/P5DT7H')
True
>>> validators.interval('23P7DT5H')
False
>>> validators.duration('P3Y6M4W7DT12H30M5S')
True
>>> validators.duration('23P7DT5H')
False
>>> validators.time('13:15+05:10')
True
>>> validators.date('1981-04-05')
True
>>> validators.date('1981-095')
True
>>> validators.date('1981-W43-1')
True
>>> validators.date('1981W43-1')
False

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iso8601utils-0.1.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

iso8601utils-0.1.1-py2.py3-none-any.whl (9.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file iso8601utils-0.1.1.tar.gz.

File metadata

  • Download URL: iso8601utils-0.1.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for iso8601utils-0.1.1.tar.gz
Algorithm Hash digest
SHA256 49df01e128f3ef247cc4783939b78d8d04e7a7c8f6526ea8d285eb432c3e8d7b
MD5 7f38a154d1855c3fc90cfcf663ac31e7
BLAKE2b-256 cc0fe8de10a05540888f17790d29bffab62703706bd938f0dc47dbf61cd7e2b7

See more details on using hashes here.

File details

Details for the file iso8601utils-0.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for iso8601utils-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 098b426ca36a99706488a48fc548c22ab761734159bca5742e254d01e721ea6f
MD5 e8dcd24d28574d58e3400868cc9500af
BLAKE2b-256 dd07aa0927c9b3910282a399281266b99aeebe31347c4934c3fee873a45402e4

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