[Python-ideas] date.datetime() method to convert from date to datetime
Evan Martin
python-dev at realityexists.net
Fri Jun 3 06:07:39 CEST 2011
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.
This isn't exactly hard to do in user code, but the obvious way of doing
it is a bit too verbose for such a simple operation. Less verbose ways
are not obvious or are error-prone, as this StackOverflow question
shows:
http://stackoverflow.com/questions/1937622/convert-date-to-datetime-in-python
--
Evan Martin
More information about the Python-ideas
mailing list