summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Twomey <michael.twomey@fieldaware.com>2014-02-27 16:43:04 +0000
committerMichael Twomey <michael.twomey@fieldaware.com>2014-02-27 16:43:04 +0000
commitabd650fad42009f635c6ebadf774f4221d54ee23 (patch)
treedd2f335547d3fca3eda39521bf2ab74f09cd88ec
parent5757f8552ded426dacf9f7c64334efe2d3f58697 (diff)
downloadpyiso8601-abd650fad42009f635c6ebadf774f4221d54ee23.tar.gz
Adding API reference to docs
-rw-r--r--README.rst2
-rw-r--r--docs/index.rst10
-rw-r--r--iso8601/iso8601.py16
-rw-r--r--setup.py2
4 files changed, 25 insertions, 5 deletions
diff --git a/README.rst b/README.rst
index e854dee..90cb809 100644
--- a/README.rst
+++ b/README.rst
@@ -5,7 +5,7 @@ This module parses the most common forms of ISO 8601 date strings (e.g.
>>> import iso8601
>>> iso8601.parse_date("2007-01-25T12:00:00Z")
-datetime.datetime(2007, 1, 25, 12, 0, tzinfo=<iso8601.iso8601.Utc ...>)
+datetime.datetime(2007, 1, 25, 12, 0, tzinfo=<iso8601.Utc>)
>>>
See the LICENSE file for the license this package is released under.
diff --git a/docs/index.rst b/docs/index.rst
index 51ec271..15e6a4a 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -10,7 +10,7 @@ This module parses the most common forms of ISO 8601 date strings (e.g. 2007-01-
>>> import iso8601
>>> iso8601.parse_date("2007-01-25T12:00:00Z")
-datetime.datetime(2007, 1, 25, 12, 0, tzinfo=<iso8601.iso8601.Utc ...>)
+datetime.datetime(2007, 1, 25, 12, 0, tzinfo=<iso8601.Utc>)
>>>
This module is released under a MIT license.
@@ -66,3 +66,11 @@ To install simply use pip::
pip install iso8601
+
+API
+===
+
+.. autofunction:: iso8601.parse_date
+
+.. autoexception:: iso8601.ParseError
+
diff --git a/iso8601/iso8601.py b/iso8601/iso8601.py
index becdd95..1ae810a 100644
--- a/iso8601/iso8601.py
+++ b/iso8601/iso8601.py
@@ -18,7 +18,7 @@ import logging
import sys
import re
-__all__ = ["parse_date", "ParseError"]
+__all__ = ["parse_date", "ParseError", "UTC"]
LOG = logging.getLogger(__name__)
@@ -79,7 +79,7 @@ class ParseError(Exception):
# Yoinked from python docs
ZERO = timedelta(0)
class Utc(tzinfo):
- """UTC
+ """UTC Timezone
"""
def utcoffset(self, dt):
@@ -91,6 +91,9 @@ class Utc(tzinfo):
def dst(self, dt):
return ZERO
+ def __repr__(self):
+ return "<iso8601.Utc>"
+
UTC = Utc()
class FixedOffset(tzinfo):
@@ -174,6 +177,15 @@ def parse_date(datestring, default_timezone=UTC):
have dates without a timezone (not strictly correct). In this case the
default timezone specified in default_timezone is used. This is UTC by
default.
+
+ :param datestring: The date to parse as a string
+ :param default_timezone: A datetime tzinfo instance to use when no timezone
+ is specified in the datestring. If this is set to
+ None then a naive datetime object is returned.
+ :returns: A datetime.datetime instance
+ :raises: ParseError when there is a problem parsing the date or
+ constructing the datetime instance.
+
"""
if not isinstance(datestring, _basestring):
raise ParseError("Expecting a string %r" % datestring)
diff --git a/setup.py b/setup.py
index 3e60572..e9dc75d 100644
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@ long_description = open(os.path.join(os.path.dirname(__file__), "README.rst")).r
setup(
name="iso8601",
- version="0.1.10",
+ version="0.1.11",
description=long_description.split("\n")[0],
long_description=long_description,
author="Michael Twomey",