Jon Ribbens schrieb:
> I see you snipped without response my request to back up your claim
> that "assuming that a date() is a datetime() with a time of midnight
> will clearly break that logic".

I've another idea. Date and datetime objects are compared by date. The
date object for a given date is always smaller than the datetime for the
same day - even for midnight. The date 2007-01-02 is smaller than
2007-01-02 00:00:00 but larger than 2007-01-01 24:00:00.

>>> date(2007, 1, 2) < datetime(2007, 1, 2, 0, 0, 0)
True
>>> date(2007, 1, 2) > datetime(2007, 1, 1, 24, 0, 0)
True
>>> date(2007, 1, 2) == datetime(2007, 1, 2, 0, 0, 0)
False
>>> date(2007, 1, 2) in datetime(2007, 1, 2, 0, 0, 0)
TypeError(...)

>>> datetime(2007, 1, 2, 0, 0, 0) < date(2007, 1, 2)
TypeError(...)
>>> datetime(2007, 1, 2, 0, 0, 0) > date(2007, 1, 2)
TypeError(...)
>>> datetime(2007, 1, 2, 0, 0, 0) == date(2007, 1, 2)
False
>>> datetime(2007, 1, 2, 0, 0, 0) in date(2007, 1, 2)
True

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to