Pull requests

#14 Merged
Repository
numegil
Branch
default
Repository
mchaput
Branch
default

Fixed a small naive/aware timezone issue

Author
  1. Alexei Gousev
Reviewers
Description

This simple fix makes Whoosh compatible with the timezone support in Django 1.4

  • Learn about pull requests

Comments (2)

    1. Alexei Gousev author

      Django 1.4 has timezone support to discriminante between timezone aware and naive datetime objects. Basically, each datetime object has a tzinfo attribute for the timezone. If it's set, then the object is considered 'aware'. (See https://docs.djangoproject.com/en/dev/topics/i18n/timezones/#concepts for details).

      In this case, if dt is timezone aware, then dt.min is still timezone naive, and trying to subtract them results in an exception.

      My hack-ish fix for this is to just convert dt to a naive object. I briefly glanced through the rest of the times.py file, and don't see anywhere else where this could be in issue at first glance, but there might be something I'm missing elsewhere.

      In any case, this fix stopped the errors I was experiencing, and appears to be working correctly.