
Collin Winter wrote:
It might be neat to add a __contains__ method to date() objects so that "datetime(2007, 1, 1, 0, 0, 0) in date(2007, 1, 1)" would be True. This would seem to fulfill the During operator.
Yeah, I had the same idea: http://permalink.gmane.org/gmane.comp.python.devel/86828 In my opinion the comparison operations for date and datetime object should be defined as: datetime before date: < -----------------------
datetime(2007, 1, 1, 23, 59, 59) < date(2007, 1, 2) True Valid for all datetimes before (smaller than) datetime(2007, 1, 2, 0, 0, 0)
datetime during date: in ------------------------
datetime(2007, 1, 2, 23, 59, 59) in date(2007, 1, 2) True Valid for all datetimes((2007, 1, 2, *, *, *).date() == date(2007, 1, 2)
datetime after date: > ----------------------
datetime(2007, 1, 3, 0, 0, 0) in date(2007, 1, 2) True Valid for all datetimes after 2007-01-02 (greater or equal 2007-01-03 00:00:00)
datetime <= date and datetime => date should raise a TypeError. The result is ambiguous. A date with time is never equal to a date. Christian