Basically what i want is to have the day of the week's date after saying next week or similar format and i though i found what i need in here:
Find the date for the first Monday after a given a date
However testing the code proved it's giving somewhat answers i'd want differently :
import datetime
def next_weekday(d, weekday):
days_ahead = weekday - d.weekday()
if days_ahead <= 0: # Target day already happened this week
days_ahead += 7
return d + datetime.timedelta(days_ahead)
d = datetime.date(2017, 11, 30)
next_monday = next_weekday(d, 0) # 0 = Monday, 1=Tuesday, 2=Wednesday...
print(next_monday)
It worked as expected to give the date correctly for next_weekday(d,0)
, 1,2,3 then for next_weekday(d,4)
i get 2017-12-01
which my system interprets as faulty because this friday
equate 2017-12-01
while next friday
equates 2017-12-08
same for saturday and Sunday, so basically what i want if the day of the week we're seeking is still in the same week to give the date of that day for the week after.