diff --git a/static/style.css b/static/style.css
new file mode 100644
index 0000000..3d19cc8
--- /dev/null
+++ b/static/style.css
@@ -0,0 +1,77 @@
+body {
+ font-family: sans-serif;
+ text-align: center;
+}
+
+span.red {
+ color: white;
+ background: red;
+ border-radius: 5px;
+ padding: 5px;
+}
+
+span.orange {
+ color: white;
+ background: orange;
+ border-radius: 5px;
+ padding: 5px;
+}
+
+span.green {
+ color: white;
+ background: green;
+ border-radius: 5px;
+ padding: 5px;
+}
+
+progress {
+ border-radius: 5px;
+ width: 80%;
+ height: 22px;
+}
+progress::-webkit-progress-bar {
+ background-color: green;
+ border-radius: 5px;
+}
+progress::-webkit-progress-value {
+ background-color: green;
+ border-radius: 5px;
+}
+progress::-moz-progress-bar {
+ background-color: green;
+ border-radius: 5px;
+}
+
+div.content {
+ width: 50%;
+ height: auto;
+ margin: 0 auto;
+ position: relative;
+}
+
+@media screen and (max-width: 1440px) {
+ div.content {
+ width: 60%;
+ height: auto;
+ margin: 0 auto;
+ position: relative;
+ }
+}
+
+@media screen and (max-width: 1080px) {
+ div.content {
+ width: 80%;
+ height: auto;
+ margin: 0 auto;
+ position: relative;
+ }
+}
+
+@media screen and (max-width: 768px) {
+ div.content {
+ width: 100%;
+ height: auto;
+ margin: 0 auto;
+ position: relative;
+ }
+}
diff --git a/templates/index.html b/templates/index.html
new file mode 100644
index 0000000..977281f
--- /dev/null
+++ b/templates/index.html
@@ -0,0 +1,24 @@
+
+
+
+
It is currently {{ nowTime }} on {{ nowDate }}.
+
+ We are {{ yearPercent }}% of the way through {{ year }}.
+
+
+
+ To put that into context:
+ If the year were
+ a 90 minute football match,
+ it would be the {{ footballMinute }}th minute.
+ a 40 hour work week,
+ it would be {{ workTime }} on {{ workDay }}.
+ a marathon,
+ you would have {{ marathonMile }} miles to go.
+
+
+
diff --git a/year-progress.py b/year-progress.py
index 9ef174d..b07b318 100644
--- a/year-progress.py
+++ b/year-progress.py
@@ -1,6 +1,7 @@
import datetime
+import math
-from flask import Flask
+from flask import Flask, render_template, url_for
app = Flask(__name__)
def num2day(num):
@@ -19,38 +20,41 @@ def num2day(num):
def workWeek(yearPercent):
totalNumHours = 40*yearPercent
numDays = totalNumHours/8
- hoursIntoDay = (numDays - round(numDays))*8
- minutesIntoDay = round((hoursIntoDay - round(hoursIntoDay))*60)
- workDatetime = datetime.datetime(year=1970,month=1,day=1,hour=round(hoursIntoDay)+9,minute=minutesIntoDay)
+ hoursIntoDay = (numDays - math.floor(numDays))*8
+ minutesIntoDay = round((hoursIntoDay - math.floor(hoursIntoDay))*60)
+ workDatetime = datetime.datetime(year=1970,month=1,day=1,hour=math.floor(hoursIntoDay)+9,minute=minutesIntoDay)
workTime = workDatetime.strftime("%-I:%M%p")
- return num2day(round(numDays+1)), workTime
-
-
+ return num2day(math.floor(numDays+1)), workTime
def getTemplate():
now = datetime.datetime.now()
nowTime = now.strftime("%-I:%M%p")
- nowDate = now.strftime("%x")
+ nowDate = now.strftime("%A") + " " + now.strftime("%-d") + " " + now.strftime("%B")
delta = now - datetime.datetime(day=1,month=1,year=now.year)
totalDays = datetime.datetime(day=1,month=1,year=now.year+1) - datetime.datetime(day=1,month=1,year=now.year)
yearPercent = delta/totalDays
+ footballMinute = math.floor(yearPercent*90)
workDay, workTime = workWeek(yearPercent)
- template = f"It is currently {nowTime}, on {nowDate}.