{"action":"created","issue":{"url":"https://api.github.com/repos/gregplaysguitar/django-eventtools/issues/9","repository_url":"https://api.github.com/repos/gregplaysguitar/django-eventtools","labels_url":"https://api.github.com/repos/gregplaysguitar/django-eventtools/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/gregplaysguitar/django-eventtools/issues/9/comments","events_url":"https://api.github.com/repos/gregplaysguitar/django-eventtools/issues/9/events","html_url":"https://github.com/gregplaysguitar/django-eventtools/issues/9","id":135462358,"number":9,"title":"Timezone support","user":{"login":"austing","id":551533,"avatar_url":"https://avatars.githubusercontent.com/u/551533?v=3","gravatar_id":"","url":"https://api.github.com/users/austing","html_url":"https://github.com/austing","followers_url":"https://api.github.com/users/austing/followers","following_url":"https://api.github.com/users/austing/following{/other_user}","gists_url":"https://api.github.com/users/austing/gists{/gist_id}","starred_url":"https://api.github.com/users/austing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/austing/subscriptions","organizations_url":"https://api.github.com/users/austing/orgs","repos_url":"https://api.github.com/users/austing/repos","events_url":"https://api.github.com/users/austing/events{/privacy}","received_events_url":"https://api.github.com/users/austing/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-22T16:07:45Z","updated_at":"2016-02-22T21:24:02Z","closed_at":null,"body":"I had some problems when I set TZ_INFO=True in settings.py. In particular, I can't call `    next_occurrence_start = self.next_occurrence(from_date=now)[0]`\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/django/core/handlers/base.py\", line 132, in get_response\r\n    response = wrapped_callback(request, *callback_args, **callback_kwargs)\r\n  File \"/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/wagtail/wagtailcore/views.py\", line 25, in serve\r\n    return page.serve(request, *args, **kwargs)\r\n  File \"/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/wagtail/contrib/wagtailroutablepage/models.py\", line 101, in serve\r\n    return view(request, *args, **kwargs)\r\n  File \"/Users/Gross/Sites/Atelier/whitebox/page/models/events_page.py\", line 90, in events_list_view\r\n    self.get_events_list()\r\n  File \"/Users/Gross/Sites/Atelier/whitebox/page/models/events_page.py\", line 83, in serialize_events_list\r\n    return events_model.preview_serializer(events, many=True).data\r\n  File \"/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/rest_framework/serializers.py\", line 658, in data\r\n    ret = super(ListSerializer, self).data\r\n  File \"/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/rest_framework/serializers.py\", line 223, in data\r\n    self._data = self.to_representation(self.instance)\r\n  File \"/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/rest_framework/serializers.py\", line 598, in to_representation\r\n    self.child.to_representation(item) for item in iterable\r\n  File \"/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/rest_framework/serializers.py\", line 447, in to_representation\r\n    attribute = field.get_attribute(instance)\r\n  File \"/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/rest_framework/fields.py\", line 401, in get_attribute\r\n    return get_attribute(instance, self.source_attrs)\r\n  File \"/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/rest_framework/fields.py\", line 76, in get_attribute\r\n    instance = getattr(instance, attr)\r\n  File \"/Users/Gross/Sites/Atelier/whitebox/page/models/events_page.py\", line 264, in next_event_occurrence\r\n    next_occurrence_start = self.next_occurrence(from_date=now)[0]\r\n  File \"/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/eventtools/models.py\", line 139, in next_occurrence\r\n    self.all_occurrences(from_date=from_date, to_date=to_date))\r\n  File \"/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/eventtools/models.py\", line 23, in first_item\r\n    return next(gen)\r\n  File \"/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/eventtools/models.py\", line 54, in combine_occurrences\r\n    next_date = next(gen)\r\n  File \"/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/eventtools/models.py\", line 331, in all_occurrences\r\n    inc=True\r\n  File \"/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/dateutil/rrule.py\", line 225, in between\r\n    if i > before:\r\nTypeError: can't compare offset-naive and offset-aware datetimes\r\n```\r\n\r\nAt this point, *i* is `datetime.datetime(2016, 2, 26, 10, 2, tzinfo=<UTC>)`, and *before* is `datetime.datetime(2016, 3, 4, 23, 59, 59)`.\r\n\r\nThe problem seems to be that *as_datetime* strips off timezone information, but the timezone information is left on the dates used in the generator."},"comment":{"url":"https://api.github.com/repos/gregplaysguitar/django-eventtools/issues/comments/187389044","html_url":"https://github.com/gregplaysguitar/django-eventtools/issues/9#issuecomment-187389044","issue_url":"https://api.github.com/repos/gregplaysguitar/django-eventtools/issues/9","id":187389044,"user":{"login":"gregplaysguitar","id":23109,"avatar_url":"https://avatars.githubusercontent.com/u/23109?v=3","gravatar_id":"","url":"https://api.github.com/users/gregplaysguitar","html_url":"https://github.com/gregplaysguitar","followers_url":"https://api.github.com/users/gregplaysguitar/followers","following_url":"https://api.github.com/users/gregplaysguitar/following{/other_user}","gists_url":"https://api.github.com/users/gregplaysguitar/gists{/gist_id}","starred_url":"https://api.github.com/users/gregplaysguitar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregplaysguitar/subscriptions","organizations_url":"https://api.github.com/users/gregplaysguitar/orgs","repos_url":"https://api.github.com/users/gregplaysguitar/repos","events_url":"https://api.github.com/users/gregplaysguitar/events{/privacy}","received_events_url":"https://api.github.com/users/gregplaysguitar/received_events","type":"User","site_admin":false},"created_at":"2016-02-22T21:24:01Z","updated_at":"2016-02-22T21:24:01Z","body":"Ah, thanks for this. I haven't used this lib with timezones yet so that hadn't popped up. I've created a pull request but there are some failing tests, if you want to have a look feel free, otherwise I can look at it later today."}}