myusuf3/delorean — pull request #34 by benhohner (2013-08-13 07:42:03+00:00)
Title: Allow initialization of non-pytz time zone aware datetimes

If a user is trying to convert a datetime **initialized with a pytz tzinfo** to Delorean the following happens:

a = datetime(2013,8,13,7,3,26,56569, tzinfo=pytz.UTC)
>>> delorean.Delorean(a)
Delorean(datetime=2013-08-13 07:03:26.056569+00:00, timezone=UTC)

But if a user is trying to convert a datetime **initialized with a non-pytz tzinfo** to Delorean the following happens:

a = datetime(2013,8,13,7,3,26,56569, tzinfo=pytz.UTC)
>>> delorean.Delorean(a)
Delorean(datetime=2013-08-13 07:03:26.056569+00:00, timezone=UTC)

>>> b = datetime(2013,8,13,7,3,26,56569, tzinfo=colander.iso8601.UTC)
delorean.Delorean(b)
Traceback (most recent call last):
File "", line 1, in
File "/home/dev/.virtualenvs/whatstolose/local/lib/python2.7/site-packages/delorean/dates.py", line 169, in __init__
zone = datetime.tzinfo.zone
AttributeError: 'Utc' object has no attribute 'zone'

Here are the docs for the tzinfo objects and the methods it should have: http://docs.python.org/release/2.5.2/lib/datetime-tzinfo.html

The change I've made should now allow delorean to work with any TZ aware datetime.