From 9426a35dbba4d8ca61a59cfff472dbb7e6782157 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Mon, 24 Oct 2011 09:35:44 +0200 Subject: Substitute the use of timedelta.total_seconds() with its actual implementation. This method was introduced in Python 2.7. --- src/pyexiv2/utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pyexiv2/utils.py b/src/pyexiv2/utils.py index 9473aff..0325699 100644 --- a/src/pyexiv2/utils.py +++ b/src/pyexiv2/utils.py @@ -28,6 +28,9 @@ Utilitary classes and functions. """ +# Enable true division. +from __future__ import division + import datetime import re @@ -601,7 +604,10 @@ class DateTimeFormatter(object): ``±%H:%M`` :rtype: string """ - seconds = t.total_seconds() + # timedelta.total_seconds() is only available starting with Python 2.7 + # (http://docs.python.org/library/datetime.html#datetime.timedelta.total_seconds) + #seconds = t.total_seconds() + seconds = (t.microseconds + (t.seconds + t.days * 24 * 3600) * 10**6) / 10**6 hours = int(seconds / 3600) minutes = abs(int((seconds - hours * 3600) / 60)) return '%+03d:%02d' % (hours, minutes) -- cgit