[Python-Dev] datetime +/- scalars (int, long, float)? (original) (raw)

Guido van Rossum guido@python.org
Sun, 03 Mar 2002 15:05:02 -0500


Would it be good to allow adding/subtracting scalars (int, long, float) to/from date/times? The scalar value would be # of seconds.

So: dt = datetime() # some date/time dt + 5 # would add 5 seconds dt + 5.3 # would add 5 seconds 300000 usecs

Yes, I think so. Timedelta should also support this, I believe. Thanks for the patch! Of course, the test suite needs to be augmented too.

BTW, we prefer comments and edits to the Wiki over the mailing list:

http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage

I've added this already.

--Guido van Rossum (home page: http://www.python.org/~guido/)