.. module:: jnrbase.iso_8601
   :synopsis: ISO-8601 support

iso_8601
========

.. note::

   This module requires ciso8601_, which :program:`pip` users can install with
   the ``jnrbase[iso_8601]`` requirement.

.. _ciso8601: https://pypi.python.org/pypi/ciso8601

Functions
---------

Duration support
''''''''''''''''

.. autofunction:: parse_delta
.. autofunction:: format_delta

Timestamp support
'''''''''''''''''

.. autofunction:: parse_datetime
.. autofunction:: format_datetime

.. _iso_8601-examples:

Examples
--------

.. testsetup::

    from jnrbase.iso_8601 import (format_datetime, format_delta, parse_delta,
                                  parse_datetime)

.. doctest::

    >>> delta = 'PT02H07M43S'
    >>> parse_delta(delta)
    datetime.timedelta(0, 7663)
    >>> format_delta(parse_delta(delta)) == delta
    True
    >>> timestamp = '2016-12-01T13:02:26Z'
    >>> parse_datetime(timestamp)
    datetime.datetime(2016, 12, 1, 13, 2, 26, tzinfo=<UTC>)
    >>> format_datetime(parse_datetime(timestamp)) == timestamp
    True
