helpers.py
changeset 55 5667d2bbdc50
parent 54 b65a95eb9f6b
child 58 ce028d356e1f
equal deleted inserted replaced
54:b65a95eb9f6b 55:5667d2bbdc50
    52             checks if the given date is today
    52             checks if the given date is today
    53         """
    53         """
    54 
    54 
    55         # construct current date
    55         # construct current date
    56         return date == self.ctx['timezone'].localize(datetime.datetime.now()).date()
    56         return date == self.ctx['timezone'].localize(datetime.datetime.now()).date()
    57         
    57     
       
    58     def prev_month_year (self, month) :
       
    59         """
       
    60             Returns the year of the month before the given one
       
    61         """
       
    62 
       
    63         if month.month == 1 :
       
    64             return month.year - 1
       
    65 
       
    66         else :
       
    67             return month.year
       
    68             
       
    69     def next_month_year (self, month) :
       
    70         """
       
    71             Returns the year of the month after the given one
       
    72         """
       
    73 
       
    74         if month.month == 12 :
       
    75             return month.year + 1
       
    76 
       
    77         else :
       
    78             return month.year
       
    79 
       
    80     def prev_month (self, month) :
       
    81         """
       
    82             Returns the month before the given one
       
    83         """
       
    84 
       
    85         if month.month == 1 :
       
    86             return 12
       
    87 
       
    88         else :
       
    89             return month.month - 1
       
    90 
       
    91     def next_month (self, month) :
       
    92         """
       
    93             Returns the month after the given one
       
    94         """
       
    95 
       
    96         if month.month == 12 :
       
    97             return 1
       
    98 
       
    99         else :
       
   100             return month.month + 1
       
   101