Вот расчет, если вы хотите узнать n-й день недели месяца:
from datetime import datetime
# n 1-5 (1st-5th weekday)
# weekday 0-6 (0=Monday)
# month 1-12
def nth_weekday(n,weekday,month,year):
if not 1 <= n <= 5:
raise ValueError('n must be 1-5')
if not 0 <= weekday <= 6:
raise ValueError('weekday must be 0-6')
if not 1 <= month <= 12:
raise ValueError('month must be 1-12')
# Determine the starting weekday of the month.
start = datetime(year,month,1)
startwday = start.weekday()
# Compute the offset to the Nth weekday.
day = (weekday -startwday) % 7 + 7 * (n - 1) + 1
target = datetime(year,month,day)
if n == 1: postfix = 'st'
elif n == 2: postfix = 'nd'
elif n == 3: postfix = 'rd'
else: postfix = 'th'
return f'The {n}{postfix} {target:%A} is {target:%B %d, %Y}.'
print(nth_weekday(1,4,11,2019))
print(nth_weekday(4,5,12,2019))
print(nth_weekday(4,3,1,2019))
Вывод:
The 1st Friday is November 01, 2019.
The 4th Saturday is December 28, 2019.
The 4th Thursday is January 24, 2019.