[Getan-commits] [PATCH 09 of 16] Add method to calculate the total duration of a project

Wald Commits scm-commit at wald.intevation.org
Mon Mar 3 15:00:40 CET 2014


# HG changeset patch
# User Björn Ricks <bjoern.ricks at intevation.de>
# Date 1393853256 -3600
# Node ID 4f5094f3f615dda215631cf99700362c5422d2d4
# Parent  5ded6192b85b5e4bd25ded4abbf57fcc453993a4
Add method to calculate the total duration of a project

diff -r 5ded6192b85b -r 4f5094f3f615 getan/project.py
--- a/getan/project.py	Mon Mar 03 14:27:08 2014 +0100
+++ b/getan/project.py	Mon Mar 03 14:27:36 2014 +0100
@@ -10,7 +10,7 @@
 
 import locale
 
-from datetime import datetime
+from datetime import datetime, timedelta
 
 
 class Project(object):
@@ -72,6 +72,12 @@
             self.load_entries()
         return self._entries
 
+    def get_total_duration(self):
+        dur = timedelta(0)
+        for entry in self.entries:
+            dur += entry.get_duration()
+        return dur
+
 
 class Entry(object):
 


More information about the Getan-commits mailing list