Merge branch 'nearest-quarter-hour'
This commit is contained in:
commit
6a3e1ccbbd
|
@ -1,13 +1,12 @@
|
|||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import fileinput
|
||||
import math
|
||||
import re
|
||||
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 +57,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
|
||||
|
@ -74,7 +73,7 @@ for act in sorted(start.keys()):
|
|||
|
||||
ind[act] = delta
|
||||
gtot += delta
|
||||
if delta <= 288:
|
||||
if nearest(delta/3600.00) == 0:
|
||||
gtoth += 0.08
|
||||
else:
|
||||
gtoth += nearest(delta/3600.00)
|
||||
|
@ -87,14 +86,14 @@ table = "{a:<50} {f:>10}"
|
|||
for act in sorted(ind.keys()):
|
||||
#minutes = "{:d}min".format(int(ind[act]%3600/60))
|
||||
#hrs = "{:d}hrs".format(int(nearest(ind[act]/3600)))
|
||||
if ind[act] <= 288:
|
||||
if nearest(ind[act]/3600.0) == 0:
|
||||
fhrs = "{:.2f}hrs".format(0.08)
|
||||
else:
|
||||
fhrs = "{:.2f}hrs".format(nearest(ind[act]/3600.00))
|
||||
#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 +108,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…
Reference in New Issue