August 2018
Intermediate to advanced
366 pages
10h 14m
English
Go through these steps:
import datetime
def monthweekdays(month, weekday):
now = datetime.datetime.utcnow()
d = now.replace(day=1, month=month, hour=0, minute=0, second=0, microsecond=0)
days = []
while d.month == month:
if d.isoweekday() == weekday:
days.append(d)
d += datetime.timedelta(days=1)
return days
>>> monthweekdays(3, 1) [datetime.datetime(2018, 3, 5, 0, 0), datetime.datetime(2018, 3, 12, 0, 0), datetime.datetime(2018, 3, 19, 0, 0), datetime.datetime(2018, ...