[Python-ideas] date.datetime() method to convert from date to datetime

Alexander Belopolsky alexander.belopolsky at gmail.com
Fri Jun 3 15:11:32 CEST 2011


On Fri, Jun 3, 2011 at 12:07 AM, Evan Martin
<python-dev at realityexists.net> wrote:
> There is a datetime.date() method for converting from a datetime to a date,
> but no stdlib method to do the opposite conversion. Could a date.datetime()
> method be added that returns a datetime with the time component set to zero?
> Alternatively, if the object is already a datetime, it could simply return
> itself.

My preferred alternative to this idea would be to allow datetime
constructor to take date (or datetime).  This would make date/datetime
behave similar to int/float.  If this is done, I would also like the
single-argument constructor to accept str in ISO format.



More information about the Python-ideas mailing list