STINNER Victor <[EMAIL PROTECTED]> added the comment: I wrote this function is my program:
def timedelta2seconds(delta): """ Convert a datetime.timedelta() objet to a number of second (floatting point number). >>> timedelta2seconds(timedelta(seconds=2, microseconds=40000)) 2.04 >>> timedelta2seconds(timedelta(minutes=1, milliseconds=250)) 60.25 """ return delta.microseconds / 1000000.0 \ + delta.seconds + delta.days * 60*60*24 About the use cases: I use it to compute the compression rate of an audio song (bytes / seconds), to compute the bit rate of a video (bytes / seconds). I'm using datetime.timedelta() to store the audio/video duration. It's not related to time_t: see issue #2736 for datetime.datetime.totimestamp(). And about time_t: I don't about 31 bits signed integer. It's not beacuse other programs have arbitrary limits than Python should also be limited. About the patch: I don't like the name "tosecs", it's not consistent with the constructor: timedelta(seconds=...).tosec[ond]s(). And why dropping the microseconds? For short duration, microseconds are useful. ---------- nosy: +haypo _______________________________________ 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