helpers.py
changeset 58 ce028d356e1f
parent 55 5667d2bbdc50
child 60 759369a79527
equal deleted inserted replaced
57:e123721e4b34 58:ce028d356e1f
    44         """
    44         """
    45             Returns a datetime.date for the given (month.year, month.month, mday)
    45             Returns a datetime.date for the given (month.year, month.month, mday)
    46         """
    46         """
    47 
    47 
    48         return datetime.date(month.year, month.month, mday)
    48         return datetime.date(month.year, month.month, mday)
       
    49     
       
    50     def now (self) :
       
    51         """
       
    52             Build current time
       
    53         """
       
    54 
       
    55         return self.ctx['timezone'].localize(datetime.datetime.now())
       
    56 
       
    57     def today (self) :
       
    58         """
       
    59             Build today's date
       
    60         """
       
    61         
       
    62         return self.now().date()
    49 
    63 
    50     def is_today (self, date) :
    64     def is_today (self, date) :
    51         """
    65         """
    52             checks if the given date is today
    66             Checks if the given date is today
    53         """
    67         """
    54 
    68 
    55         # construct current date
    69         # construct current date
    56         return date == self.ctx['timezone'].localize(datetime.datetime.now()).date()
    70         return date == self.today()
    57     
    71     
       
    72     def is_this_month (self, month) :
       
    73         """
       
    74             Checks the given month is the current month
       
    75         """
       
    76 
       
    77         today = self.today()
       
    78 
       
    79         return (month.year == today.year and month.month == today.month)
       
    80 
    58     def prev_month_year (self, month) :
    81     def prev_month_year (self, month) :
    59         """
    82         """
    60             Returns the year of the month before the given one
    83             Returns the year of the month before the given one
    61         """
    84         """
    62 
    85