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

M.-A. Lemburg mal@lemburg.com
Mon, 04 Mar 2002 11:54:00 +0100


Guido van Rossum wrote:
> 
> > 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.

Hope you don't mind ;-) ...

You should name the type timestamp if you want to imply dt + n
== dt + n seconds. datetime + n is commonly understood as
dt + n *days*.

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Software:                   http://www.egenix.com/files/python/