myusuf3 / delorean

Delorean: Time Travel Made Easy
http://delorean.rtfd.org/
MIT License
1.84k stars 128 forks source link

Tzinfo #42

Closed aliirz closed 10 years ago

aliirz commented 10 years ago

Hi everyone I am trying to use the stops feature in my code like this:

         count = 0

        for stop in stops(freq=delorean.DAILY, count=7, start=d1, stop=d2):
            if(stop.date == mydate):
                count = count + 1

But I keep getting this error:

AttributeError: 'datetime.date' object has no attribute 'tzinfo'

I dont understand what I am doing wrong. Will really appreciate the help.

Best

myusuf3 commented 10 years ago

@aliirz I need more context around this issue. what is stop? what is mydate, d1, d2? maybe send a gist, with sample code.

cdesales commented 10 years ago

I got the same error using more or less this code:

from datetime import date, date time
from delorean import Delorean

dt = date(2013, 5, 06)
dl = Delorean(dt, timezone="UTC")

This is the workaround I used:

from datetime import date, datetime
from delorean import Delorean

dt = date(2013, 5, 06)
dl = Delorean(datetime(dt.year, dt.month, dt.day), timezone="UTC")