MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / HTMLCalendar

Class HTMLCalendar

tools/python-3.11.9-amd64/Lib/calendar.py:412–545  ·  view source on GitHub ↗

This calendar returns complete HTML pages.

Source from the content-addressed store, hash-verified

410
411
412class HTMLCalendar(Calendar):
413 """
414 This calendar returns complete HTML pages.
415 """
416
417 # CSS classes for the day <td>s
418 cssclasses = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"]
419
420 # CSS classes for the day <th>s
421 cssclasses_weekday_head = cssclasses
422
423 # CSS class for the days before and after current month
424 cssclass_noday = "noday"
425
426 # CSS class for the month's head
427 cssclass_month_head = "month"
428
429 # CSS class for the month
430 cssclass_month = "month"
431
432 # CSS class for the year's table head
433 cssclass_year_head = "year"
434
435 # CSS class for the whole year table
436 cssclass_year = "year"
437
438 def formatday(self, day, weekday):
439 """
440 Return a day as a table cell.
441 """
442 if day == 0:
443 # day outside month
444 return '<td class="%s">&nbsp;</td>' % self.cssclass_noday
445 else:
446 return '<td class="%s">%d</td>' % (self.cssclasses[weekday], day)
447
448 def formatweek(self, theweek):
449 """
450 Return a complete week as a table row.
451 """
452 s = ''.join(self.formatday(d, wd) for (d, wd) in theweek)
453 return '<tr>%s</tr>' % s
454
455 def formatweekday(self, day):
456 """
457 Return a weekday name as a table header.
458 """
459 return '<th class="%s">%s</th>' % (
460 self.cssclasses_weekday_head[day], day_abbr[day])
461
462 def formatweekheader(self):
463 """
464 Return a header for a week as a table row.
465 """
466 s = ''.join(self.formatweekday(i) for i in self.iterweekdays())
467 return '<tr>%s</tr>' % s
468
469 def formatmonthname(self, theyear, themonth, withyear=True):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected