code: def formatmonth(self, theyear, themonth, withyear=True,
                      previous_month=None, next_month=None):
          
          self.current_year = theyear
          self.current_month = themonth
          self.day_entries = [date.day
                              for date in Entry.published.filter(
                                  publication_date__year=theyear,
                                  publication_date__month=themonth
                                  ).datetimes('publication_date', 'day')]
          v = []
          a = v.append
          a('<table class="%s">' % (
              self.day_entries and 'entries-calendar' or 'no-entries-calendar'))
          a('\n')
          a(self.formatmonthname(theyear, themonth, withyear=withyear))
          a('\n')
          a(self.formatweekheader())
          a('\n')
          a(self.formatfooter(previous_month, next_month))
          a('\n<tbody>\n')
          for week in self.monthdays2calendar(theyear, themonth):
              a(self.formatweek(week))
              a('\n')
          a('</tbody>\n</table>')
          a('\n')
          return ''.join(v)
docs: Return a formatted month as a table
          with new attributes computed for formatting a day,
          and thead/tfooter.