Changes between Initial Version and Version 1 of Ticket #29190, comment 2


Ignore:
Timestamp:
Mar 7, 2018, 11:04:44 AM (7 years ago)
Author:
Derek Shoemaker

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #29190, comment 2

    initial v1  
    1 From the code for `django.utils.timezone`:
    2 
    3   By design, [is_aware doesn't] perform any checks on [its] arguments. The caller should ensure that they don't receive an invalid value like None.
    4 
    5   Assuming value.tzinfo is either None or a proper datetime.tzinfo, value.utcoffset() implements the appropriate logic.
    6 
    7 So the function does not accept date objects. It only accepts datetime and time objects, since they the necessary time information to determine timezone. The date object is naive and does not have either tzinfo or utcoffset as methods.
    8 
    9 https://docs.python.org/3/library/datetime.html#datetime.date
    10 
    11 I don't know your use case exactly, but I think that replacing the date object with a datetime object will fix your problem.
     1(whoops, didn't see someone already commented)
Back to Top