helpers.py
changeset 55 5667d2bbdc50
parent 54 b65a95eb9f6b
child 58 ce028d356e1f
--- a/helpers.py	Mon Feb 09 04:39:24 2009 +0200
+++ b/helpers.py	Mon Feb 09 05:44:29 2009 +0200
@@ -54,4 +54,48 @@
 
         # construct current date
         return date == self.ctx['timezone'].localize(datetime.datetime.now()).date()
-        
+    
+    def prev_month_year (self, month) :
+        """
+            Returns the year of the month before the given one
+        """
+
+        if month.month == 1 :
+            return month.year - 1
+
+        else :
+            return month.year
+            
+    def next_month_year (self, month) :
+        """
+            Returns the year of the month after the given one
+        """
+
+        if month.month == 12 :
+            return month.year + 1
+
+        else :
+            return month.year
+
+    def prev_month (self, month) :
+        """
+            Returns the month before the given one
+        """
+
+        if month.month == 1 :
+            return 12
+
+        else :
+            return month.month - 1
+
+    def next_month (self, month) :
+        """
+            Returns the month after the given one
+        """
+
+        if month.month == 12 :
+            return 1
+
+        else :
+            return month.month + 1
+