Skip to main content

Generate and parse RFC 3339 timestamps

Project description

Description

Build Status Documentation Status

pyRFC3339 parses and generates RFC 3339-compliant timestamps using Python datetime.datetime objects.

>>> from pyrfc3339 import generate, parse
>>> from datetime import datetime, timezone
>>> generate(datetime.now(timezone.utc)) #doctest:+ELLIPSIS
'...T...Z'
>>> parse('2009-01-01T10:01:02Z')
datetime.datetime(2009, 1, 1, 10, 1, 2, tzinfo=datetime.timezone.utc)
>>> parse('2009-01-01T14:01:02-04:00')
datetime.datetime(2009, 1, 1, 14, 1, 2, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=72000), '<UTC-04:00>'))

Installation

To install the latest version from PyPI:

$ pip install pyRFC3339

To install the latest development version:

$ pip install https://github.com/kurtraschke/pyRFC3339/tarball/master#egg=pyRFC3339-dev

To build the documentation with Sphinx:

  1. $ pip install -r docs/requirements.txt

  2. $ sphinx-build -M html docs/source/ docs/build

The documentation is also available online at:

https://pyrfc3339.readthedocs.io/

Supported by

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