helpers.py
changeset 115 751e3fcd11d2
parent 114 d4848d807fd1
child 131 67f5d2fdca1d
equal deleted inserted replaced
114:d4848d807fd1 115:751e3fcd11d2
    44 
    44 
    45         return _calendar.day_abbr[wday]
    45         return _calendar.day_abbr[wday]
    46 
    46 
    47     def build_date (self, month, mday) :
    47     def build_date (self, month, mday) :
    48         """
    48         """
    49             Returns a datetime.date for the given (month.year, month.month, mday)
    49             Returns a datetime.datetime for the given (month.year, month.month, mday)
    50         """
    50         """
    51 
    51 
    52         return datetime.date(month.year, month.month, mday)
    52         return self.ctx['prefs'][preferences.timezone].localize(datetime.datetime(month.year, month.month, mday))
    53     
    53     
    54     def now (self) :
    54     def now (self) :
    55         """
    55         """
    56             Build current time
    56             Build current time
    57         """
    57         """
    63             Build today's date
    63             Build today's date
    64         """
    64         """
    65         
    65         
    66         return self.now().date()
    66         return self.now().date()
    67 
    67 
    68     def is_today (self, date) :
    68     def is_today (self, dt) :
    69         """
    69         """
    70             Checks if the given date is today
    70             Checks if the given datetime.datetime is today
    71         """
    71         """
    72 
    72 
    73         # construct current date
    73         # compare with current date
    74         return date == self.today()
    74         return dt.date() == self.today()
    75     
    75     
    76     def is_this_month (self, month) :
    76     def is_this_month (self, month) :
    77         """
    77         """
    78             Checks the given month is the current month
    78             Checks the given month is the current month
    79         """
    79         """