# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1236696009 -3600 # Node ID f5be65616a315461df4096c83924ca75a1b2cfde # Parent 25ec009daa95b23d48840444024de3862cd84563 more datetime fixes and cleanup diff -r 25ec009daa95 -r f5be65616a31 web/views/calendar.py --- a/web/views/calendar.py Tue Mar 10 15:39:53 2009 +0100 +++ b/web/views/calendar.py Tue Mar 10 15:40:09 2009 +0100 @@ -21,7 +21,7 @@ # useful constants & functions ################################################ -ONEDAY = timedelta(1, 0) +ONEDAY = timedelta(1) WEEKDAYS = (_("monday"), _("tuesday"), _("wednesday"), _("thursday"), _("friday"), _("saturday"), _("sunday")) @@ -144,12 +144,12 @@ month = _today.month first_day_of_month = date(year, month, 1) - firstday = first_day_of_month - timedelta(first_day_of_month.weekday(), 0, 0) + firstday = first_day_of_month - timedelta(first_day_of_month.weekday()) if month >= 12: - last_day_of_month = date(year + 1, 1, 1) - timedelta(1, 0, 0) + last_day_of_month = date(year + 1, 1, 1) - timedelta(1) else: - last_day_of_month = date(year, month + 1, 1) - timedelta(1, 0, 0) - lastday = last_day_of_month + timedelta(6 - last_day_of_month.weekday(), 0, 0) + last_day_of_month = date(year, month + 1, 1) - timedelta(1) + lastday = last_day_of_month + timedelta(6 - last_day_of_month.weekday()) month_dates = list(date_range(firstday, lastday)) dates = {} users = [] @@ -254,8 +254,8 @@ self.w(u'') def _prevnext_links(self, curdate): - prevdate = curdate - timedelta(31, 0, 0) - nextdate = curdate + timedelta(31, 0, 0) + prevdate = curdate - timedelta(31) + nextdate = curdate + timedelta(31) rql = self.rset.printable_rql() prevlink = ajax_replace_url('onemonthcalid', rql, 'onemonthcal', year=prevdate.year, month=prevdate.month) @@ -330,8 +330,8 @@ else: week = _today.isocalendar()[1] # week - 1 since we get week number > 0 while we want it to start from 0 - first_day_of_week = strptime('%s-%s-1' % (year, week - 1), '%Y-%U-%w') - lastday = first_day_of_week + timedelta(6, 0, 0) + first_day_of_week = todate(strptime('%s-%s-1' % (year, week - 1), '%Y-%U-%w')) + lastday = first_day_of_week + timedelta(6) firstday = first_day_of_week dates = [[] for i in range(7)] task_max = 0 @@ -385,13 +385,13 @@ # output header self.w(u'