python 2.6 safe total_seconds

This commit is contained in:
Chris Meyers
2015-07-30 13:40:31 -04:00
parent b0f55c832d
commit f64a48a98f
3 changed files with 17 additions and 7 deletions

View File

@@ -511,3 +511,11 @@ def timestamp_apiformat(timestamp):
if timestamp.endswith('+00:00'):
timestamp = timestamp[:-6] + 'Z'
return timestamp
# damn you python 2.6
def timedelta_total_seconds(timedelta):
return (
timedelta.microseconds + 0.0 +
(timedelta.seconds + timedelta.days * 24 * 3600) * 10 ** 6) / 10 ** 6