Skip to content

Instantly share code, notes, and snippets.

@jamilnoyda
Last active May 22, 2022 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamilnoyda/9a81dcc59f695f6ebd48359f366d83f7 to your computer and use it in GitHub Desktop.
Save jamilnoyda/9a81dcc59f695f6ebd48359f366d83f7 to your computer and use it in GitHub Desktop.
from datetime import date, timedelta
print("enter date in this fromat year month date[yyyy mm dd]")
sdate = input("enter start date: ")
edate = input("enter end date: ")
print(
"enter exact this words for weekday sunday monday tuesday wednesday thursday friday saturday"
)
weekday = input("enter weekday: ")
# weekday = "sunday"
yyyy, mm, dd = sdate.split()
eyyyy, emm, edd = edate.split()
sdate = date(int(yyyy), int(mm), int(dd)) # start date
edate = date(int(eyyyy), int(emm), int(edd)) # end date
# sdate = date(2020, 9, 12) # start date
# edate = date(2020, 9, 13) # end date
delta = edate - sdate # as timedelta
for i in range(delta.days + 1):
d = {
0: "monday",
1: "tuesday",
2: "wednesday",
3: "thursday",
4: "friday",
5: "saturday",
6: "sunday",
}
if weekday == d.get(day.weekday()):
day = sdate + timedelta(days=i)
print(day)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment