This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients brett.cannon, catlee, erik.stephens, guettli, jribbens, lemburg, skip.montanaro, steve.roberts, tim.peters, tomster, vstinner
Date 2008-10-31.18:12:22
SpamBayes Score 9.127691e-06
Marked as misclassified No
Message-id <1225476746.23.0.155854035789.issue1673409@psf.upfronthosting.co.za>
In-reply-to
Content
New patch based on catlee's patch: add toseconds() method to timedelta 
but use the float type to keep the microseconds. The error between the 
exact value and IEEE754 value is small: the error is smaller than one 
second even with 999999999 days:

 - with less than 16 days, the microsecond error is smaller than 
0,01%.
 - with less than 1000 days, the microsecond error is smaller than 1%
 - with 99500 days or more, the microsecond error is bigger than 90%

To compute the error in microseconds:
>>> d=100; m=1
>>> e=abs((timedelta(days=d, microseconds=m).toseconds() - 
d*86400)*1e6 - m)
>>> e*100/m
0.024044513702392578

For the seconds, this is no error even with 999999999 days. Error in 
seconds:

>>> d=999999999; s=1; timedelta(days=d, seconds=m).toseconds() - 
d*86400, s
(1.0, 1)

(no error, both values are the same)
History
Date User Action Args
2008-10-31 18:12:26vstinnersetrecipients: + vstinner, lemburg, tim.peters, skip.montanaro, brett.cannon, jribbens, guettli, catlee, tomster, erik.stephens, steve.roberts
2008-10-31 18:12:26vstinnersetmessageid: <1225476746.23.0.155854035789.issue1673409@psf.upfronthosting.co.za>
2008-10-31 18:12:25vstinnerlinkissue1673409 messages
2008-10-31 18:12:24vstinnercreate