diff mbox

Don't use total_seconds for python < 2.7

Message ID 1371135056-6465-1-git-send-email-mricon@kernel.org
State Accepted
Headers show

Commit Message

Konstantin Ryabitsev June 13, 2013, 2:50 p.m. UTC
The total_seconds function was added to datetime in python-2.7. For
compatibility with previous versions of python, use its suggested
equivalent (except drop microseconds, since we don't care about them in
this context).

Signed-off-by: Konstantin Ryabitsev <mricon@kernel.org>
---
 apps/patchwork/views/__init__.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jeremy Kerr June 27, 2013, 1:16 p.m. UTC | #1
Hi Konstantin,

> The total_seconds function was added to datetime in python-2.7. For
> compatibility with previous versions of python, use its suggested
> equivalent (except drop microseconds, since we don't care about them in
> this context).

Thanks for that - applied.

Cheers,


Jeremy
diff mbox

Patch

diff --git a/apps/patchwork/views/__init__.py b/apps/patchwork/views/__init__.py
index 681532a..a823388 100644
--- a/apps/patchwork/views/__init__.py
+++ b/apps/patchwork/views/__init__.py
@@ -190,8 +190,8 @@  def patch_to_mbox(patch):
     if patch.content:
         body += '\n' + patch.content
 
-    utc_timestamp = (patch.date -
-            datetime.datetime.utcfromtimestamp(0)).total_seconds()
+    delta = patch.date - datetime.datetime.utcfromtimestamp(0)
+    utc_timestamp = delta.seconds + delta.days*24*3600
 
     mail = PatchMbox(body)
     mail['Subject'] = patch.name