I have a day name such as Monday. and the current day is Wednesday. Now i want to get the date of next coming Monday. How can i do it with a best practice in a very short way. right now i am trying to do this with bunch of if conditions and it made things messy and very difficult.
here is my code :
day_time = timezone.now()
current_day = day_time.strftime("%A")
coming_day = "monday"
if coming_day == current_day:
day_time = day_time
if coming_day=="sunday" and coming_day == "monday":
day_time = day_time + timedelta(days=6)
if coming_day=="sunday" and coming_day == "tuesday":
day_time = day_time + timedelta(days=5)
if coming_day=="sunday" and coming_day == "wednesday":
day_time = day_time + timedelta(days=4)
if coming_day=="sunday" and coming_day == "thursday":
day_time = day_time + timedelta(days=3)
.........so on