MCPcopy Index your code
hub / github.com/python/cpython / HTMLCalendar

Class HTMLCalendar

Lib/calendar.py:469–617  ·  view source on GitHub ↗

This calendar returns complete HTML pages.

Source from the content-addressed store, hash-verified

467
468
469class HTMLCalendar(Calendar):
470 """
471 This calendar returns complete HTML pages.
472 """
473
474 # CSS classes for the day <td>s
475 cssclasses = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"]
476
477 # CSS classes for the day <th>s
478 cssclasses_weekday_head = cssclasses
479
480 # CSS class for the days before and after current month
481 cssclass_noday = "noday"
482
483 # CSS class for the month's head
484 cssclass_month_head = "month"
485
486 # CSS class for the month
487 cssclass_month = "month"
488
489 # CSS class for the year's table head
490 cssclass_year_head = "year"
491
492 # CSS class for the whole year table
493 cssclass_year = "year"
494
495 def formatday(self, day, weekday):
496 """
497 Return a day as a table cell.
498 """
499 if day == 0:
500 # day outside month
501 return f'<td class="{self.cssclass_noday}">&nbsp;</td>'
502 else:
503 return f'<td class="{self.cssclasses[weekday]}">{day}</td>'
504
505 def formatweek(self, theweek):
506 """
507 Return a complete week as a table row.
508 """
509 s = ''.join(self.formatday(d, wd) for (d, wd) in theweek)
510 return f'<tr>{s}</tr>'
511
512 def formatweekday(self, day):
513 """
514 Return a weekday name as a table header.
515 """
516 return f'<th class="{self.cssclasses_weekday_head[day]}">{day_abbr[day]}</th>'
517
518 def formatweekheader(self):
519 """
520 Return a header for a week as a table row.
521 """
522 s = ''.join(self.formatweekday(i) for i in self.iterweekdays())
523 return f'<tr>{s}</tr>'
524
525 def formatmonthname(self, theyear, themonth, withyear=True):
526 """

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…