Preparing git repo for final project

This commit is contained in:
2023-07-09 11:19:26 +02:00
parent 6a38966eef
commit 63d06d6b35
67 changed files with 1587 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
import re
months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
def main():
while True:
try:
entered_date = input("Date: ").strip()
except Exception:
continue
if re.match(r"\d+/\d+/\d+", entered_date):
month, day, year = map(int, entered_date.split('/'))
elif re.match(r"\w+ \d{1,2}, \d{4}", entered_date):
entered_date = entered_date.replace(",", "")
month, day, year = entered_date.split(' ')
month = months.index(month) + 1
day, year = map(int, (day, year))
else:
continue
if month > 12 or day > 31:
continue
break
print(f"{year:04d}-{month:02d}-{day:02d}")
if __name__ == "__main__":
main()