From 1e7dc2207440683132be17ddd62930821d906323 Mon Sep 17 00:00:00 2001 From: Andrew Conlin Date: Fri, 9 Aug 2024 17:10:09 +0100 Subject: [PATCH] [2024-08-09] Initial commit, text-based Need to use strftime and the time module to properly format the times --- .gitignore | 1 + year-progress.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 .gitignore create mode 100644 year-progress.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..64dc10b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.year-progress diff --git a/year-progress.py b/year-progress.py new file mode 100644 index 0000000..a5866b2 --- /dev/null +++ b/year-progress.py @@ -0,0 +1,46 @@ +import datetime + +def num2day(num): + match num: + case 1: + return "Monday" + case 2: + return "Tuesday" + case 3: + return "Wednesday" + case 4: + return "Thursday" + case 5: + return "Friday" + +def workWeek(yearPercent): + totalNumHours = 40*yearPercent + numDays = totalNumHours/8 + hoursIntoDay = (numDays - round(numDays))*8 + minutesIntoDay = round((hoursIntoDay - round(hoursIntoDay))*60) + return num2day(round(numDays+1)), round(hoursIntoDay)+9, minutesIntoDay + +currentTime = datetime.datetime.now() +print (f"It is currently {currentTime.hour}:{currentTime.minute}, on {currentTime.day}/{currentTime.month}/{currentTime.year}.") + +delta = currentTime - datetime.datetime(day=1,month=1,year=currentTime.year) +total_days = datetime.datetime(day=1,month=1,year=currentTime.year+1) - datetime.datetime(day=1,month=1,year=currentTime.year) + +yearPercent = delta/total_days +print(f"We are {round(yearPercent*100,2)}% of the way through {currentTime.year}.") + +print("To put that into context:") + +print("If the year were") + +print(" a 90 minute football match,") +print(f" it would be the {round(yearPercent*90)}th minute.") + +day, hours, minutes = workWeek(yearPercent) +print(" a 40 hour work week,") +print(f" it would be {hours}:{minutes} on {day}.") + +#abbey road +#marathon world record +#the hobbit +