[Python-Dev] datetime module enhancements (original) (raw)

Jon Ribbens jon+python-dev at unequivocal.co.uk
Fri Mar 9 22:20:33 CET 2007


Brett Cannon <brett at python.org> 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.

I personally like the current solution. The proposal to just assume midnight goes against EIBTI in my mind.

Not in mine. The comparison of a date with a datetime throwing an exception is astonishing in my mind.

The problem is, if you don't define a 'date' as I suggest (i.e. midnight at the start of the day in question), then what does a 'date' represent?

If you want the answer to be "an unknown time on that day" then you need to alter the datetime module so that subtracting one date from another throws an exception.

If you want the answer to be "the entire of that day" then you need to alter the datetime module so that, e.g. subtracting 2007-03-08 from 2007-03-09 does not return "one day" as currently, but returns "zero days" instead (since of course there is no time between the end of one day and the start of the next day).

Obviously both of those alternatives are ludicrous (not to mention they would break backwards-compatibility), so I would suggest the only logical solution is to make the change I proposed ;-)



More information about the Python-Dev mailing list