[hamster-applet] let's keep the format_duration still in stuff



commit 661418cec42d7166594f190367e899040252c213
Author: Toms Bauģis <toms baugis gmail com>
Date:   Thu Nov 19 12:51:07 2009 +0000

    let's keep the format_duration still in stuff

 hamster/stats.py               |    4 ++--
 hamster/stuff.py               |   38 ++++++++++++++++++++++++++++++++++++++
 hamster/tools/__init__.py      |   38 --------------------------------------
 hamster/tools/activityentry.py |    2 +-
 hamster/tools/dateinput.py     |    2 +-
 hamster/tools/timeinput.py     |    2 +-
 6 files changed, 43 insertions(+), 43 deletions(-)
---
diff --git a/hamster/stats.py b/hamster/stats.py
index 9b9413d..cc0da99 100644
--- a/hamster/stats.py
+++ b/hamster/stats.py
@@ -856,7 +856,7 @@ than 15 minutes you seem to be a busy bee." % ("<b>%d</b>" % short_percent))
             day_row = self.fact_store.append(None,
                                              [-1,
                                               fact_date,
-                                              tools.format_duration(day_total),
+                                              stuff.format_duration(day_total),
                                               current_date.strftime('%Y-%m-%d'),
                                               "",
                                               "",
@@ -867,7 +867,7 @@ than 15 minutes you seem to be a busy bee." % ("<b>%d</b>" % short_percent))
                                        [fact["id"],
                                         fact["start_time"].strftime('%H:%M') + " " +
                                         fact["name"],
-                                        tools.format_duration(fact["delta"]),
+                                        stuff.format_duration(fact["delta"]),
                                         fact["start_time"].strftime('%Y-%m-%d'),
                                         fact["description"],
                                         fact["category"],
diff --git a/hamster/stuff.py b/hamster/stuff.py
index c52ae8e..a1e13a6 100644
--- a/hamster/stuff.py
+++ b/hamster/stuff.py
@@ -33,6 +33,44 @@ import re
 import locale
 import os
 
+def format_duration(minutes, human = True):
+    """formats duration in a human readable format.
+    accepts either minutes or timedelta"""
+    
+    if isinstance(minutes, dt.timedelta):
+        minutes = duration_minutes(minutes)
+        
+    if not minutes:
+        if human:
+            return ""
+        else:
+            return "00:00"
+    
+    hours = minutes / 60
+    minutes = minutes % 60
+    formatted_duration = ""
+    
+    if human:
+        if minutes % 60 == 0:
+            # duration in round hours
+            formatted_duration += _("%dh") % (hours)
+        elif hours == 0:
+            # duration less than hour
+            formatted_duration += _("%dmin") % (minutes % 60.0)
+        else:
+            # x hours, y minutes
+            formatted_duration += _("%dh %dmin") % (hours, minutes % 60)
+    else:
+        formatted_duration += "%02d:%02d" % (hours, minutes)
+    
+    
+    return formatted_duration
+
+def duration_minutes(duration):
+    """returns minutes from duration, otherwise we keep bashing in same math"""
+    return duration.seconds / 60 + duration.days * 24 * 60
+
+
 def load_ui_file(name):
     from configuration import runtime
     ui = gtk.Builder()
diff --git a/hamster/tools/__init__.py b/hamster/tools/__init__.py
index dc5fbde..a68bea2 100644
--- a/hamster/tools/__init__.py
+++ b/hamster/tools/__init__.py
@@ -52,41 +52,3 @@ def add_hint(entry, hint):
 
     entry._set_hint(entry, None)
 
-
-
-def format_duration(minutes, human = True):
-    """formats duration in a human readable format.
-    accepts either minutes or timedelta"""
-    
-    if isinstance(minutes, dt.timedelta):
-        minutes = duration_minutes(minutes)
-        
-    if not minutes:
-        if human:
-            return ""
-        else:
-            return "00:00"
-    
-    hours = minutes / 60
-    minutes = minutes % 60
-    formatted_duration = ""
-    
-    if human:
-        if minutes % 60 == 0:
-            # duration in round hours
-            formatted_duration += _("%dh") % (hours)
-        elif hours == 0:
-            # duration less than hour
-            formatted_duration += _("%dmin") % (minutes % 60.0)
-        else:
-            # x hours, y minutes
-            formatted_duration += _("%dh %dmin") % (hours, minutes % 60)
-    else:
-        formatted_duration += "%02d:%02d" % (hours, minutes)
-    
-    
-    return formatted_duration
-
-def duration_minutes(duration):
-    """returns minutes from duration, otherwise we keep bashing in same math"""
-    return duration.seconds / 60 + duration.days * 24 * 60
diff --git a/hamster/tools/activityentry.py b/hamster/tools/activityentry.py
index d9692ff..099a9c5 100644
--- a/hamster/tools/activityentry.py
+++ b/hamster/tools/activityentry.py
@@ -20,7 +20,7 @@
 from hamster import tools
 from hamster.configuration import GconfStore, runtime
 
-from stuff import format_duration
+from hamster.stuff import format_duration
 import gtk
 import datetime as dt
 import calendar
diff --git a/hamster/tools/dateinput.py b/hamster/tools/dateinput.py
index ef18365..ffdf0c1 100644
--- a/hamster/tools/dateinput.py
+++ b/hamster/tools/dateinput.py
@@ -17,7 +17,7 @@
 # You should have received a copy of the GNU General Public License
 # along with Project Hamster.  If not, see <http://www.gnu.org/licenses/>.
 
-from hamster.tools import format_duration
+from hamster.stuff import format_duration
 import gtk
 import datetime as dt
 import calendar
diff --git a/hamster/tools/timeinput.py b/hamster/tools/timeinput.py
index a060813..337fc9e 100644
--- a/hamster/tools/timeinput.py
+++ b/hamster/tools/timeinput.py
@@ -17,7 +17,7 @@
 # You should have received a copy of the GNU General Public License
 # along with Project Hamster.  If not, see <http://www.gnu.org/licenses/>.
 
-from hamster.tools import format_duration
+from hamster.stuff import format_duration
 import gtk
 import datetime as dt
 import calendar



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