cleaning time_spent formating

This commit is contained in:
Jachym Cepicky
2019-06-16 10:25:29 +02:00
parent 0de263280f
commit 37c6905d46
7 changed files with 49 additions and 8 deletions

View File

@ -291,3 +291,18 @@ def query_tickets_by_args(objects, order_by, **kwargs):
'total': total,
'draw': draw
}
def format_time_spent(time_spent):
"""Format time_spent attribute to "[H]HHh:MMm" text string to be allign in
all graphical outputs
"""
if time_spent:
time_spent = "{0:02d}h:{0:02d}m".format(
int(time_spent.total_seconds() // 3600),
int((time_spent.total_seconds() % 3600) / 60)
)
else:
time_spent = ""
return time_spent