mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Fix calculation of totals longer than a day
datetime.timedelta stores days, seconds and microseconds. Therefore the seconds attribute only stores timedeltas of less than 24 hours. Use total_seconds() instead which properly accounts for the days part.
This commit is contained in:
parent
cd0d5d175e
commit
8053ccf68e
2 changed files with 39 additions and 4 deletions
|
@ -133,13 +133,15 @@ def calculate_totals(input_stream):
|
|||
# Compose table rows.
|
||||
grand_total = 0
|
||||
for tag in sorted(totals):
|
||||
formatted = format_seconds(totals[tag].seconds)
|
||||
grand_total += totals[tag].seconds
|
||||
seconds = int(totals[tag].total_seconds())
|
||||
formatted = format_seconds(seconds)
|
||||
grand_total += seconds
|
||||
output.append("{:{width}} {:10}".format(tag, formatted, width=max_width))
|
||||
|
||||
if untagged is not None:
|
||||
formatted = format_seconds(untagged.seconds)
|
||||
grand_total += untagged.seconds
|
||||
seconds = int(untagged.total_seconds())
|
||||
formatted = format_seconds(seconds)
|
||||
grand_total += seconds
|
||||
output.append("{:{width}} {:10}".format("", formatted, width=max_width))
|
||||
|
||||
# Compose total.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue