From abd650fad42009f635c6ebadf774f4221d54ee23 Mon Sep 17 00:00:00 2001 From: Michael Twomey Date: Thu, 27 Feb 2014 16:43:04 +0000 Subject: Adding API reference to docs --- README.rst | 2 +- docs/index.rst | 10 +++++++++- iso8601/iso8601.py | 16 ++++++++++++++-- setup.py | 2 +- 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=) +datetime.datetime(2007, 1, 25, 12, 0, tzinfo=) >>> 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=) +datetime.datetime(2007, 1, 25, 12, 0, tzinfo=) >>> 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 "" + 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", -- cgit v1.2.1