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 tim.peters
Recipients belopolsky, facundobatista, r.david.murray, tim.peters
Date 2014-07-24.18:01:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1406224906.59.0.243618558365.issue22058@psf.upfronthosting.co.za>
In-reply-to
Content
Was the title of this meant to be

"datetime.date() should accept a datetime.datetime as init parameter"

instead?  That's what the example appears to be getting at.

If so, -1.  Datetime objects already have .date(), .time(), and .timetz() methods to extract, respectively, the date, naive time, and aware time portions of the datetime object.  In the other direction, the datetime .combine() constructor builds a datetime object out of date and time components.  As the docs say,

"For any datetime object d, d == datetime.combine(d.date(), d.timetz())"

Another way to spell this isn't needed.

> There is currently no obvious way to convert either date
> or datetime instance to date.

some_datetime_object.date() is the obvious way to extract a date object from a datetime object.

I don't know what it could mean to convert a date object to a date.  That's pretty much exactly like asking how to convert an int object to an int.  Huh? ;-)  date and int objects are immutable, so a need to make a copy (if that's what is meant) rarely arises.
History
Date User Action Args
2014-07-24 18:01:46tim.peterssetrecipients: + tim.peters, facundobatista, belopolsky, r.david.murray
2014-07-24 18:01:46tim.peterssetmessageid: <1406224906.59.0.243618558365.issue22058@psf.upfronthosting.co.za>
2014-07-24 18:01:46tim.peterslinkissue22058 messages
2014-07-24 18:01:46tim.peterscreate