diff options
-rw-r--r-- | .hgignore | 2 | ||||
-rw-r--r-- | README | 5 | ||||
-rw-r--r-- | dev-requirements.txt | 2 | ||||
-rw-r--r-- | iso8601/__init__.py | 2 | ||||
-rw-r--r-- | iso8601/iso8601.py | 9 | ||||
-rw-r--r-- | iso8601/test_iso8601.py | 10 | ||||
-rw-r--r-- | setup.py | 16 | ||||
-rw-r--r-- | tox.ini | 6 |
8 files changed, 42 insertions, 10 deletions
@@ -3,3 +3,5 @@ build dist *.pyc iso8601.egg-info +pyiso8601-venv +.tox @@ -30,3 +30,8 @@ If you want more full featured parsing look at: - http://labix.org/python-dateutil - python-dateutil This was originally hosted at https://code.google.com/p/pyiso8601/ + +Testing: + +1. pip install -r dev-requirements.txt +2. tox diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 0000000..4bb63bb --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1,2 @@ +pytest >= 2.3.5 +tox >= 1.6.0 diff --git a/iso8601/__init__.py b/iso8601/__init__.py index e72e356..11b1adc 100644 --- a/iso8601/__init__.py +++ b/iso8601/__init__.py @@ -1 +1 @@ -from iso8601 import * +from .iso8601 import * diff --git a/iso8601/iso8601.py b/iso8601/iso8601.py index f923938..38266c3 100644 --- a/iso8601/iso8601.py +++ b/iso8601/iso8601.py @@ -9,10 +9,17 @@ datetime.datetime(2007, 1, 25, 12, 0, tzinfo=<iso8601.iso8601.Utc ...>) """ from datetime import datetime, timedelta, tzinfo +import sys import re __all__ = ["parse_date", "ParseError"] +if sys.version_info >= (3, 0, 0): + _basestring = str +else: + _basestring = basestring + + # Adapted from http://delete.me.uk/2005/03/iso8601.html ISO8601_REGEX = re.compile(r"(?P<year>[0-9]{4})(-(?P<month>[0-9]{1,2})(-(?P<day>[0-9]{1,2})" r"((?P<separator>.)(?P<hour>[0-9]{2}):(?P<minute>[0-9]{2})(:(?P<second>[0-9]{2})(\.(?P<fraction>[0-9]+))?)?" @@ -86,7 +93,7 @@ def parse_date(datestring, default_timezone=UTC): default timezone specified in default_timezone is used. This is UTC by default. """ - if not isinstance(datestring, basestring): + if not isinstance(datestring, _basestring): raise ParseError("Expecting a string %r" % datestring) m = ISO8601_REGEX.match(datestring) if not m: diff --git a/iso8601/test_iso8601.py b/iso8601/test_iso8601.py index ff9e273..44cdc77 100644 --- a/iso8601/test_iso8601.py +++ b/iso8601/test_iso8601.py @@ -1,4 +1,6 @@ -import iso8601 +from __future__ import absolute_import + +from iso8601 import iso8601 def test_iso8601_regex(): assert iso8601.ISO8601_REGEX.match("2006-10-11T00:14:33Z") @@ -32,7 +34,7 @@ def test_parse_date_fraction(): def test_parse_date_fraction_2(): """From bug 6 - + """ d = iso8601.parse_date("2007-5-7T11:43:55.328Z'") assert d.year == 2007 @@ -76,7 +78,7 @@ def test_parse_invalid_date2(): def test_parse_no_timezone(): """issue 4 - Handle datetime string without timezone - + This tests what happens when you parse a date with no timezone. While not strictly correct this is quite common. I'll assume UTC for the time zone in this case. @@ -98,7 +100,7 @@ def test_parse_no_timezone_different_default(): def test_space_separator(): """Handle a separator other than T - + """ d = iso8601.parse_date("2007-06-23 06:40:34.00Z") assert d.year == 2007 @@ -16,6 +16,14 @@ datetime.datetime(2007, 1, 25, 12, 0, tzinfo=<iso8601.iso8601.Utc ...>) Changes ======= +0.1.5 +----- + +* Wow, it's alive! First update since 2007 +* Moved over to https://bitbucket.org/micktwomey/pyiso8601 +* Applied patch from https://code.google.com/p/pyiso8601/issues/detail?id=23 (thanks to zefciu), add support for python 3 +* Switched to py.test and tox for testing + 0.1.4 ----- @@ -25,7 +33,7 @@ Changes 0.1.3 ----- -* Fixed the microsecond handling, the generated microsecond values were +* Fixed the microsecond handling, the generated microsecond values were way too small. Fixes issue 9. 0.1.2 @@ -34,7 +42,7 @@ Changes * Adding ParseError to __all__ in iso8601 module, allows people to import it. Addresses issue 7. * Be a little more flexible when dealing with dates without leading zeroes. - This violates the spec a little, but handles more dates as seen in the + This violates the spec a little, but handles more dates as seen in the field. Addresses issue 6. * Allow date/time separators other than T. @@ -47,12 +55,12 @@ Changes setup( name="iso8601", - version="0.1.4", + version="0.1.5", description=long_description.split("\n")[0], long_description=long_description, author="Michael Twomey", author_email="micktwomey+iso8601@gmail.com", - url="http://code.google.com/p/pyiso8601/", + url="https://bitbucket.org/micktwomey/pyiso8601", packages=["iso8601"], license="MIT", ) @@ -0,0 +1,6 @@ +[tox] +envlist = py26,py27,py32,py33 + +[testenv] +deps=pytest +commands=py.test iso8601 |