hours: accumulate total_hours by summing rounded daily values
This commit is contained in:
parent
f92dc5c5e6
commit
6fc67ca06d
15
hours
15
hours
@ -71,7 +71,7 @@ def main(argv):
|
|||||||
|
|
||||||
border = lambda: sys.stdout.write('-' * 40 + '\n')
|
border = lambda: sys.stdout.write('-' * 40 + '\n')
|
||||||
|
|
||||||
total_seconds = 0
|
total_hours = 0
|
||||||
border()
|
border()
|
||||||
for time in times:
|
for time in times:
|
||||||
if time[0] is not None:
|
if time[0] is not None:
|
||||||
@ -81,18 +81,17 @@ def main(argv):
|
|||||||
if time[1] is not None:
|
if time[1] is not None:
|
||||||
sys.stdout.write(fmt_time_dt(time[1]))
|
sys.stdout.write(fmt_time_dt(time[1]))
|
||||||
seconds = (time[1] - time[0]).seconds
|
seconds = (time[1] - time[0]).seconds
|
||||||
hours = seconds / 60.0 / 60.0
|
hours = round(seconds / 60.0 / 60.0, 1)
|
||||||
sys.stdout.write(' (%.1f hours)' % round(hours, 1))
|
sys.stdout.write(' (%.1f hours)' % hours)
|
||||||
total_seconds += seconds
|
total_hours += hours
|
||||||
else:
|
else:
|
||||||
sys.stdout.write('???')
|
sys.stdout.write('???')
|
||||||
sys.stdout.write('\n')
|
sys.stdout.write('\n')
|
||||||
border()
|
border()
|
||||||
sys.stdout.write('Total: %.1f hours' % round(seconds / 60.0 / 60.0, 1))
|
sys.stdout.write('Total: %.1f hours' % round(total_hours, 1))
|
||||||
|
|
||||||
secs_in_total_hours = goal_hours * 60 * 60
|
if total_hours < goal_hours:
|
||||||
if total_seconds < secs_in_total_hours:
|
out_time = now + timedelta(0, (goal_hours - total_hours) * 60 * 60)
|
||||||
out_time = now + timedelta(0, secs_in_total_hours - total_seconds)
|
|
||||||
sys.stdout.write('; %.1f at: %s %s' % (goal_hours,
|
sys.stdout.write('; %.1f at: %s %s' % (goal_hours,
|
||||||
out_time.strftime('%a %d'), fmt_time_dt(out_time)))
|
out_time.strftime('%a %d'), fmt_time_dt(out_time)))
|
||||||
sys.stdout.write('\n')
|
sys.stdout.write('\n')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user