Ticket #3306: preventing_datefilter_overflow.diff

File preventing_datefilter_overflow.diff, 750 bytes (added by ymasuda <ymasuda@…>, 18 years ago)

Patch on django.utils.tzinfo to prevent Date(Time)Field's overflowerror

  • utils/tzinfo.py

     
    4646        return time.tzname[self._isdst(dt)]
    4747
    4848    def _isdst(self, dt):
    49         tt = (dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1)
     49        # clip year value in range which time.mktime accepts
     50        if dt.year<1970:
     51            year = 1970
     52        elif dt.year>2037:
     53            year = 2037
     54        else:
     55            year = dt.year
     56        tt = (year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1)
    5057        stamp = time.mktime(tt)
    5158        tt = time.localtime(stamp)
    5259        return tt.tm_isdst > 0
Back to Top