helpers.py
changeset 73 5a7188bf2894
parent 72 5ade0288f2ec
child 79 43ac75054d5c
--- a/helpers.py	Mon Feb 09 22:17:10 2009 +0200
+++ b/helpers.py	Mon Feb 09 23:49:57 2009 +0200
@@ -6,7 +6,7 @@
 
 import qmsk.web.helpers
 
-import preferences, urls
+import preferences, urls, config
 
 class Helpers (qmsk.web.helpers.Helpers) :
     """
@@ -18,14 +18,14 @@
             Returns a string describing the given timezone
         """
 
-        return self.now().strftime("%Z%z")
+        return self.now().strftime(config.TIMEZONE_FMT)
 
     def fmt_month (self, date) :
         """
             Formats a month
         """
 
-        return date.strftime('%B %Y')
+        return date.strftime(config.MONTH_FMT)
         
     def fmt_weekday (self, wday) :
         """
@@ -151,4 +151,40 @@
         """
 
         return urls.types['ts'].build(dtz)
+    
+    def skip_next (self, count, skip) :
+        """
+            Return skip offset for next page
+        """
 
+        return count + skip
+    
+    def skip_page (self, count, page) :
+        """
+            Skip to page
+        """
+
+        if page :
+            return count * page
+
+        else :
+            return None
+
+    def skip_prev (self, count, skip) :
+        """
+            Return skip offset for previous page, None for first page
+        """
+
+        if skip > count :
+            return skip - count
+
+        else :
+            return None
+
+    def max (self, *values) :
+        """
+            Returns the largest of the given values
+        """
+
+        return max(values)
+