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

Method itermonthdays3

Lib/calendar.py:267–283  ·  view source on GitHub ↗

Like itermonthdates(), but will yield (year, month, day) tuples. Can be used for dates outside of datetime.date range.

(self, year, month)

Source from the content-addressed store, hash-verified

265 yield d, i % 7
266
267 def itermonthdays3(self, year, month):
268 """
269 Like itermonthdates(), but will yield (year, month, day) tuples. Can be
270 used for dates outside of datetime.date range.
271 """
272 day1, ndays = monthrange(year, month)
273 days_before = (day1 - self.firstweekday) % 7
274 days_after = (self.firstweekday - day1 - ndays) % 7
275 y, m = _prevmonth(year, month)
276 end = _monthlen(y, m) + 1
277 for d in range(end-days_before, end):
278 yield y, m, d
279 for d in range(1, ndays + 1):
280 yield year, month, d
281 y, m = _nextmonth(year, month)
282 for d in range(1, days_after + 1):
283 yield y, m, d
284
285 def itermonthdays4(self, year, month):
286 """

Callers 3

itermonthdatesMethod · 0.95
itermonthdays4Method · 0.95
test_itermonthdays3Method · 0.80

Calls 4

monthrangeFunction · 0.85
_prevmonthFunction · 0.85
_monthlenFunction · 0.85
_nextmonthFunction · 0.85

Tested by 1

test_itermonthdays3Method · 0.64