Ticket #17294: timezone.py.patch

File timezone.py.patch, 994 bytes (added by Daniel Swarbrick, 13 years ago)
  • django/utils/timezone.py

     
    235235    The logic is described in Python's docs:
    236236    http://docs.python.org/library/datetime.html#datetime.tzinfo
    237237    """
    238     return value.tzinfo is not None and value.tzinfo.utcoffset(value) is not None
     238    if value is not None:
     239        return value.tzinfo is not None and value.tzinfo.utcoffset(value) is not None
     240    else:
     241        return False
    239242
    240243def is_naive(value):
    241244    """
     
    244247    The logic is described in Python's docs:
    245248    http://docs.python.org/library/datetime.html#datetime.tzinfo
    246249    """
    247     return value.tzinfo is None or value.tzinfo.utcoffset(value) is None
     250    if value is not None:
     251        return value.tzinfo is None or value.tzinfo.utcoffset(value) is None
     252    else:
     253        return False
    248254
    249255def make_aware(value, timezone):
    250256    """
Back to Top