Converted to Python3, round to nearest quarter hour

nearest-quarter-hour
Trey Blancher 1 year ago
parent ac2a397c19
commit 30fe02f133
  1. 14
      timetracker.py

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
import fileinput
import math
@ -7,7 +7,7 @@ import sys
import time
def nearest(hr):
return math.ceil(hr*4)/4
return round(hr*4)/4
# Variables
start = {} # Data structure for storing the beginning of a time frame
@ -58,12 +58,12 @@ for act in sorted(start.keys()):
else: ec = 0
if bc - ec > 1:
print >> sys.stderr, "ERROR: Missing more than one End"
print("ERROR: Missing more than one End", file=sys.stderr)
sys.exit(2)
elif bc > ec: # bc should be exactly one greater
start[act].pop()
elif ec > bc:
print >> sys.stderr, "ERROR: Missing a Begin"
print("ERROR: Missing a Begin", file=sys.stderr)
sys.exit(1)
delta = 0
@ -94,7 +94,7 @@ for act in sorted(ind.keys()):
#sec = "{:d}s".format(int(ind[act]))
#print table.format(a=act, s=sec, h=hrs, m=minutes, f=fhrs)
print table.format(a=act, f=fhrs)
print(table.format(a=act, f=fhrs))
# if case.match(act):
# ttot += ind[act]
# else:
@ -109,8 +109,8 @@ total = "{t:<20} {h:>10}"
#gtots = "{:d}s".format(int(gtot))
gtoth = "{:3.2f}hrs".format(gtoth)
print
print()
#print total.format(t="Incident total:", s=ttots, h=ttoth)
#print total.format(t="Unnumbered total:", s=utots, h=utoth)
print total.format(t="Section total:", h=gtoth)
print(total.format(t="Section total:", h=gtoth))

Loading…
Cancel
Save