[Python-Dev] datetime module enhancements
python-dev at zesty.ca
Sat Mar 10 02:26:17 CET 2007
On Sat, 10 Mar 2007, Greg Ewing wrote:
> Collin Winter wrote:
> > Treat dates as if they have a time-part of midnight. This is my preferred
> > solution, and it is already what the datetime module does, for example,
> > when subtracting two dates.
> Does it really? Seems to me you can pick any time of day
> to be the representative time and get the same result
> when subtracting two dates, as long as you pick the same
> one for both dates. So it's not really assuming anything
It certainly gives that appearance:
>>> from datetime import datetime
>>> datetime(2007, 1, 2) - datetime(2007, 1, 1, 0, 0, 0)
'1 day, 0:00:00'
The behaviour to the end user exposes the midnight assumption,
regardless whether it's explained by saying the constructor
makes the assumption or the subtraction makes the assumption.
More information about the Python-Dev