[work] Fix negative timedelta printing
This commit is contained in:
parent
26e52e5bce
commit
ef4e34a7f1
1 changed files with 5 additions and 1 deletions
6
bin/work
6
bin/work
|
@ -43,10 +43,14 @@ def signal_handler(signal, frame):
|
||||||
|
|
||||||
|
|
||||||
def td_format(td):
|
def td_format(td):
|
||||||
|
prefix = ""
|
||||||
|
if td < timedelta(0):
|
||||||
|
td = -td
|
||||||
|
prefix = "-"
|
||||||
hours, remainder = divmod(td.total_seconds(), 3600)
|
hours, remainder = divmod(td.total_seconds(), 3600)
|
||||||
minutes, seconds = divmod(remainder, 60)
|
minutes, seconds = divmod(remainder, 60)
|
||||||
|
|
||||||
return '{:d}:{:02d}'.format(int(hours), int(minutes))
|
return '{}{:d}:{:02d}'.format(prefix, int(hours), int(minutes))
|
||||||
|
|
||||||
|
|
||||||
def get_today_fields():
|
def get_today_fields():
|
||||||
|
|
Loading…
Reference in a new issue