Converted to Python3, round to nearest quarter hour
This commit is contained in:
parent
ac2a397c19
commit
30fe02f133
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import fileinput
|
import fileinput
|
||||||
import math
|
import math
|
||||||
|
@ -7,7 +7,7 @@ import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
def nearest(hr):
|
def nearest(hr):
|
||||||
return math.ceil(hr*4)/4
|
return round(hr*4)/4
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
start = {} # Data structure for storing the beginning of a time frame
|
start = {} # Data structure for storing the beginning of a time frame
|
||||||
|
@ -58,12 +58,12 @@ for act in sorted(start.keys()):
|
||||||
else: ec = 0
|
else: ec = 0
|
||||||
|
|
||||||
if bc - ec > 1:
|
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)
|
sys.exit(2)
|
||||||
elif bc > ec: # bc should be exactly one greater
|
elif bc > ec: # bc should be exactly one greater
|
||||||
start[act].pop()
|
start[act].pop()
|
||||||
elif ec > bc:
|
elif ec > bc:
|
||||||
print >> sys.stderr, "ERROR: Missing a Begin"
|
print("ERROR: Missing a Begin", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
delta = 0
|
delta = 0
|
||||||
|
@ -94,7 +94,7 @@ for act in sorted(ind.keys()):
|
||||||
#sec = "{:d}s".format(int(ind[act]))
|
#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, 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):
|
# if case.match(act):
|
||||||
# ttot += ind[act]
|
# ttot += ind[act]
|
||||||
# else:
|
# else:
|
||||||
|
@ -109,8 +109,8 @@ total = "{t:<20} {h:>10}"
|
||||||
#gtots = "{:d}s".format(int(gtot))
|
#gtots = "{:d}s".format(int(gtot))
|
||||||
gtoth = "{:3.2f}hrs".format(gtoth)
|
gtoth = "{:3.2f}hrs".format(gtoth)
|
||||||
|
|
||||||
print
|
print()
|
||||||
#print total.format(t="Incident total:", s=ttots, h=ttoth)
|
#print total.format(t="Incident total:", s=ttots, h=ttoth)
|
||||||
#print total.format(t="Unnumbered total:", s=utots, h=utoth)
|
#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…
Reference in New Issue