A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2007-March/071859.html below:

[Python-Dev] datetime module enhancements

[Python-Dev] datetime module enhancementsChristian Heimes lists at cheimes.de
Sun Mar 11 22:56:10 CET 2007
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

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4