aboutsummaryrefslogtreecommitdiff
path: root/satscalc.py
diff options
context:
space:
mode:
authorSan Jacobs2021-10-03 22:27:40 +0200
committerSan Jacobs2021-10-03 22:27:40 +0200
commitcd88c1d86c1fbac87e2c089be659520913f3cd61 (patch)
treee4577ed3e2ad228960e6229752e72fd130f1ad3e /satscalc.py
parentcac1dbd23662b1d8f344ed1867c487f0d1c4de12 (diff)
downloadsatscalc-cd88c1d86c1fbac87e2c089be659520913f3cd61.tar.gz
satscalc-cd88c1d86c1fbac87e2c089be659520913f3cd61.tar.bz2
satscalc-cd88c1d86c1fbac87e2c089be659520913f3cd61.zip
More basic functionality
Diffstat (limited to 'satscalc.py')
-rwxr-xr-xsatscalc.py38
1 files changed, 32 insertions, 6 deletions
diff --git a/satscalc.py b/satscalc.py
index 878ba76..6e733cc 100755
--- a/satscalc.py
+++ b/satscalc.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import time
+import datetime
# TODO: Prompt user for base rate, call time, wrap time, whether overtime was warned, and if it was a weekend.
# This should be enough to calculate the pay for a single day's work.
@@ -9,12 +9,38 @@ hourly_rate = baserate/7.5
print("Hourly rate:", str(hourly_rate))
-# TODO: Investigate if storing multiple calltimes and wraptimes will require a custom datastructure
+print("\nTime to add your hours of work.")
+
+def timeInput(prompt):
+ while True:
+ i = input(prompt)
+ if i=="": return ""
+ elif len(i)==4: break
+ print("Wrong format. Try again.")
+
+ t = datetime.datetime.strptime(i,"%H%M")
+
+ return t
while True:
- # TODO: Check for valid format
- calltime = input("Your call time (hhmm): ")
- if calltime == "done":
+ calltime = timeInput("Your call time (24-hour format, hhmm. Leave blank to continue.): ")
+ if calltime == "":
break
- wraptime = input("Your wrap time (hhmm): ")
+ wraptime = timeInput("Your wrap time (24-hour format, hhmm): ")
+
+ # Make sure we're not traveling backwards in time
+ if wraptime < calltime:
+ wraptime = wraptime.replace(day=wraptime.day+1)
+ difference = wraptime-calltime
+ hours_worked = difference.total_seconds()/3600
+ # TODO: This part makes no sense. Don't worry. It'll be made to make sense.
+
+ input("Was this a weekend? [y/n]: ")
+
+ if hours_worked > 8:
+ print("Overtime detected.")
+ input("Was this overtime warned about before 12 o'clock the day before? [y/n]: ")
+
+print("\nDifference:",difference)
+print("Hours worked:",hours_worked)