Last active
May 22, 2022 08:22
-
-
Save jamilnoyda/9a81dcc59f695f6ebd48359f366d83f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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