diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2011-10-24 09:35:44 +0200 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2011-10-24 09:35:44 +0200 |
commit | 9426a35dbba4d8ca61a59cfff472dbb7e6782157 (patch) | |
tree | 206f15c579634ebec8ddfabe542f0e2096c63fc7 | |
parent | 5267093545dcc19666ceb925cbe7cedb9be0c449 (diff) | |
download | pyexiv2-9426a35dbba4d8ca61a59cfff472dbb7e6782157.tar.gz |
Substitute the use of timedelta.total_seconds() with its actual implementation.
This method was introduced in Python 2.7.
-rw-r--r-- | src/pyexiv2/utils.py | 8 |
1 files changed, 7 insertions, 1 deletions
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) |