[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Re: Difference between two dates in seconds
From:       "Claes at work" <claesatwork () gmail ! com>
Date:       2006-09-27 18:58:42
Message-ID: 495c267b0609271158o52aa1165xfc878aa02729b8aa () mail ! gmail ! com
[Download RAW message or body]

On 9/27/06, Fredrik Lundh <fredrik@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.

Claes
-- 
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic