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

Method formatyear

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

Returns a year's calendar as a multi-line string.

(self, theyear, w=2, l=1, c=6, m=3)

Source from the content-addressed store, hash-verified

368 return s
369
370 def formatyear(self, theyear, w=2, l=1, c=6, m=3):
371 """
372 Returns a year's calendar as a multi-line string.
373 """
374 w = max(2, w)
375 l = max(1, l)
376 c = max(2, c)
377 colwidth = (w + 1) * 7 - 1
378 v = []
379 a = v.append
380 a(repr(theyear).center(colwidth*m+c*(m-1)).rstrip())
381 a('\n'*l)
382 header = self.formatweekheader(w)
383 for (i, row) in enumerate(self.yeardays2calendar(theyear, m)):
384 # months in this row
385 months = range(m*i+1, min(m*(i+1)+1, 13))
386 a('\n'*l)
387 names = (self.formatmonthname(theyear, k, colwidth, False)
388 for k in months)
389 a(formatstring(names, colwidth, c).rstrip())
390 a('\n'*l)
391 headers = (header for k in months)
392 a(formatstring(headers, colwidth, c).rstrip())
393 a('\n'*l)
394 # max number of weeks for this row
395 height = max(len(cal) for cal in row)
396 for j in range(height):
397 weeks = []
398 for cal in row:
399 if j >= len(cal):
400 weeks.append('')
401 else:
402 weeks.append(self.formatweek(cal[j], w))
403 a(formatstring(weeks, colwidth, c).rstrip())
404 a('\n' * l)
405 return ''.join(v)
406
407 def pryear(self, theyear, w=0, l=0, c=6, m=3):
408 """Print a year's calendar."""

Callers 2

pryearMethod · 0.95
mainFunction · 0.95

Calls 12

formatweekheaderMethod · 0.95
formatmonthnameMethod · 0.95
formatweekMethod · 0.95
maxFunction · 0.85
enumerateFunction · 0.85
minFunction · 0.85
formatstringFunction · 0.85
yeardays2calendarMethod · 0.80
rstripMethod · 0.45
centerMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected