STINNER Victor <[EMAIL PROTECTED]> added the comment: 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) ---------- keywords: +patch Added file: http://bugs.python.org/file11919/timedelta_toseconds_float.patch _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1673409> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com