diff options
author | Alexander Artemenko <svetlyak.40wt@gmail.com> | 2012-10-15 15:12:28 +0000 |
---|---|---|
committer | Alexander Artemenko <svetlyak.40wt@gmail.com> | 2012-10-15 15:43:29 +0000 |
commit | 547dc32bba8911fb0976a117566079bcd66076d7 (patch) | |
tree | b71f313a06cd075aba11acd17c18f8026882b0a7 | |
parent | 906fbededc9486dddae568ffdf7f9f9d393149a3 (diff) | |
download | times-547dc32bba8911fb0976a117566079bcd66076d7.tar.gz |
Adds Python3 compatibility, using `six` module.
Also, Travis config was added, to run tests against python 2.7 and 3.2.
-rw-r--r-- | .travis.yml | 9 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | times/__init__.py | 8 |
4 files changed, 18 insertions, 5 deletions
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..def8382 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: python +python: + - "2.7" + - "3.2" +install: + - pip install nose==1.2.1 + - pip install pytz + - pip install python-dateutil>=2.1 +script: nosetests @@ -1,6 +1,9 @@ Times ===== +Build status: +[![Build Status](https://secure.travis-ci.org/svetlyak40wt/times.png)](http://travis-ci.org/svetlyak40wt/times) + Times is a small, minimalistic, Python library for dealing with time conversions to and from timezones, for once and for all. @@ -114,4 +117,3 @@ a timezone instance or a timezone string. are advised to use `times.format()` directly instead. [3]: http://labix.org/python-dateutil#head-c0e81a473b647dfa787dc11e8c69557ec2c3ecd2 - @@ -27,7 +27,7 @@ setup( include_package_data=True, zip_safe=False, platforms='any', - install_requires=['pytz', 'python-dateutil >= 2.1'], + install_requires=['pytz', 'python-dateutil >= 2.1', 'six'], classifiers=[ # As from http://pypi.python.org/pypi?%3Aaction=list_classifiers #'Development Status :: 1 - Planning', diff --git a/times/__init__.py b/times/__init__.py index 7f5865c..eef19f3 100644 --- a/times/__init__.py +++ b/times/__init__.py @@ -1,6 +1,8 @@ import datetime import calendar import pytz +import six + from dateutil.parser import parse from .version import VERSION @@ -18,7 +20,7 @@ def to_universal(local_dt, timezone=None): 'Timezone argument illegal when using UNIX timestamps.' ) return from_unix(local_dt) - elif isinstance(local_dt, basestring): + elif isinstance(local_dt, six.string_types): local_dt = parse(local_dt) return from_local(local_dt, timezone) @@ -36,7 +38,7 @@ def from_local(local_dt, timezone=None): 'argument.' ) - if isinstance(timezone, basestring): + if isinstance(timezone, six.string_types): timezone = pytz.timezone(timezone) dt_with_tzinfo = timezone.localize(local_dt) else: @@ -68,7 +70,7 @@ def to_local(dt, timezone): raise ValueError( 'First argument to to_local() should be a universal time.' ) - if isinstance(timezone, basestring): + if isinstance(timezone, six.string_types): timezone = pytz.timezone(timezone) return pytz.utc.localize(dt).astimezone(timezone) |