[Python-Dev] datetime module enhancements

Jon Ribbens jon+python-dev at unequivocal.co.uk
Sat Mar 10 14:29:09 CET 2007

Christian Heimes <lists at cheimes.de> wrote:
> > What do you feel "next Tuesday plus 12 hours" means? ;-)
> First thought: It's nonsense! Nobody would say that. ;)
> Second though: Tuesday noon (12h after the beginning of Tuesday)

I agree with you entirely. Your suggestions correspond to 'throw an
exception' and 'return a datetime'. Note that in the second case you
are agreeing with me that a date means midnight at the start of that
date ;-)

Python datetime disagrees with us both. It basically says 'add the
timedelta to midnight at the start of the date, then return just
the date part of the result'.

I assume there is some reason for this surprising behaviour. But this
is another example of where datetime is taking a pragmatic approach in
an ambiguous situation - exactly as I am suggesting in the situation
of comparing a date and a datetime.

More information about the Python-Dev mailing list