[hamster-applet/gnome-2-30] rounding error in the grand total. fixes bug 622027



commit 7fbeba207bba2184103d1920647a0fface4e66e7
Author: Toms Bauģis <toms baugis gmail com>
Date:   Sun Jun 20 23:28:23 2010 +0100

    rounding error in the grand total. fixes bug 622027

 src/hamster/overview_totals.py |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/hamster/overview_totals.py b/src/hamster/overview_totals.py
index b937465..4082125 100644
--- a/src/hamster/overview_totals.py
+++ b/src/hamster/overview_totals.py
@@ -138,18 +138,17 @@ class TotalsBox(gtk.VBox):
     def do_charts(self):
         if not self.facts:
             return
+        facts = self.facts
 
-        import copy
-        facts = copy.deepcopy(self.facts)
+        total_hours = dt.timedelta()
 
-        total_hours = sum([stuff.duration_minutes(fact["delta"]) for fact in facts])
-        total_label = _("%s hours tracked total") % ("%.1f" % (total_hours / 60.0))
-        self.get_widget("total_hours").set_text(total_label)
 
 
         category_sums, activity_sums, tag_sums = defaultdict(dt.timedelta), defaultdict(dt.timedelta), defaultdict(dt.timedelta),
 
         for fact in facts:
+            total_hours += fact["delta"]
+
             if self.selected_categories and fact["category"] not in self.selected_categories:
                 continue
             if self.selected_activities and fact["name"] not in self.selected_activities:
@@ -162,6 +161,9 @@ class TotalsBox(gtk.VBox):
             for tag in fact["tags"]:
                 tag_sums[tag] += fact["delta"]
 
+        total_label = _("%s hours tracked total") % locale.format("%.1f", stuff.duration_minutes(total_hours) / 60.0)
+        self.get_widget("total_hours").set_text(total_label)
+
 
         for key in category_sums:
             category_sums[key] = stuff.duration_minutes(category_sums[key]) / 60.0



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]