Difference between two dates in seconds

Claes at work claesatwork at gmail.com
Wed Sep 27 20:58:42 CEST 2006

On 9/27/06, Fredrik Lundh <fredrik at pythonware.com> wrote:
> Claes at work wrote:
> why would you have to do that yourself?  why not let Python do it for
> you?  here's the code:
>     seconds = td.days * 86400 + td.seconds

Thanks, but that is exactly what I meant. I had hoped there would some
method that would return the delta in seconds. Something like
td.getSeconds(), and then not only the second part but the actual
number of seconds in the interval.

This is not a big deal in the sense that it is hard to do the above
calculation, and I don't want this to come off as a rant. Perhaps I am
just not used to Python yet. But I find the timedelta API unintuitive
in that it exposes its internal representation but does not add the
convenience I was expecting. From an object oriented standpoint I
would have preferred if the internal representation was private and
there were methods to get the result converted to arbitrary units.


More information about the Python-list mailing list