This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients belopolsky, facundobatista, r.david.murray, tim.peters
Date 2014-07-24.18:29:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1406226569.73.0.867812119212.issue22058@psf.upfronthosting.co.za>
In-reply-to
Content
> some_datetime_object.date() is the obvious way to extract a
> date object from a datetime object.

Sorry if I was not clear enough about my use case.  I often have to deal with functions that are designed to take either date or datetime object as an argument, but only use date components.  In most cases this works automatically because datetime is a subclass of date.  However, there are some annoying exceptions.  For example, x > date(2001, 1, 1) will not work if x is a datetime instance.  If in this example I write x.date() > date(2001, 1, 1) - I get the opposite problem - it won't work when x is a date instance.

The "obvious" way would be date(x) > date(2001, 1, 1).

Can you suggest anything better than date(*x.timetuple()[:3]) > date(2001, 1, 1) here?
History
Date User Action Args
2014-07-24 18:29:29belopolskysetrecipients: + belopolsky, tim.peters, facundobatista, r.david.murray
2014-07-24 18:29:29belopolskysetmessageid: <1406226569.73.0.867812119212.issue22058@psf.upfronthosting.co.za>
2014-07-24 18:29:29belopolskylinkissue22058 messages
2014-07-24 18:29:29belopolskycreate