diff options
author | Johan Lundberg <lundberg@nordu.net> | 2014-03-20 14:01:49 +0100 |
---|---|---|
committer | Johan Lundberg <lundberg@nordu.net> | 2014-03-20 14:01:49 +0100 |
commit | 7b42ba9df55362b7e095f97c1a9de6e8bf4fe228 (patch) | |
tree | 9643c9043e57288d74e8f33326e2295602f901a6 /meetingtools/apps/stats | |
parent | 02723c27c2d2adfcc0c73504bb4c26fbe0a24b51 (diff) |
Fixed a Python 2.7 only attribute for timedelta.
Diffstat (limited to 'meetingtools/apps/stats')
-rw-r--r-- | meetingtools/apps/stats/models.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/meetingtools/apps/stats/models.py b/meetingtools/apps/stats/models.py index 495bd65..39e7bbb 100644 --- a/meetingtools/apps/stats/models.py +++ b/meetingtools/apps/stats/models.py @@ -21,7 +21,12 @@ class UserMeetingTransaction(models.Model): def seconds(self): delta = self.date_closed - self.date_created - return delta.total_seconds() + if hasattr(delta, 'total_seconds'): + # Python 2.7 + return delta.total_seconds() + else: + # Python 2.6 + return (delta.microseconds + (delta.seconds + delta.days * 24 * 3600) * 10 ** 6) / 10 ** 6 def __unicode__(self): return "(%d) %d seconds in %s" % (self.txid,self.seconds(),self.sco) |