diff options
author | Michael Twomey <michael.twomey@fieldaware.com> | 2014-02-27 16:43:04 +0000 |
---|---|---|
committer | Michael Twomey <michael.twomey@fieldaware.com> | 2014-02-27 16:43:04 +0000 |
commit | abd650fad42009f635c6ebadf774f4221d54ee23 (patch) | |
tree | dd2f335547d3fca3eda39521bf2ab74f09cd88ec /iso8601/iso8601.py | |
parent | 5757f8552ded426dacf9f7c64334efe2d3f58697 (diff) | |
download | pyiso8601-abd650fad42009f635c6ebadf774f4221d54ee23.tar.gz |
Adding API reference to docs
Diffstat (limited to 'iso8601/iso8601.py')
-rw-r--r-- | iso8601/iso8601.py | 16 |
1 files changed, 14 insertions, 2 deletions
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) |