From fe714bb3853388d16f0ccce7fda08436c69101ed Mon Sep 17 00:00:00 2001 From: Tobias Schmidl Date: Wed, 28 Apr 2021 10:03:59 +0200 Subject: [PATCH] Give the time only in minutes, to save space --- timewarrior.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/timewarrior.py b/timewarrior.py index d5e9042..768d9fe 100755 --- a/timewarrior.py +++ b/timewarrior.py @@ -34,8 +34,10 @@ RESULTS = sorted(map( }, TW.summary()), key=lambda x: x['start']) IS_ACTIVE = len(list(filter(lambda x: "end" not in x, TW.summary()))) > 0 - -print("⏳" if IS_ACTIVE else "⌛", str(functools.reduce(lambda total, x: total + x['end'] - x['start'], RESULTS, timedelta())).split(sep='.', maxsplit=1)[0], "✓" if not IS_ACTIVE else "") +TOTAL_TIME = functools.reduce(lambda total, x: total + x['end'] - x['start'], RESULTS, timedelta()) +TOTAL_TIME_HOURS, TOTAL_TIME_REMAINDER = divmod(int(TOTAL_TIME.total_seconds()), 3600) +TOTAL_TIME_MINUTES, _ = divmod(TOTAL_TIME_REMAINDER, 60) +print("⏳" if IS_ACTIVE else "⌛", f"{TOTAL_TIME_HOURS:02}:{TOTAL_TIME_MINUTES:02}", "✓" if not IS_ACTIVE else "") print("---") print( " | font=monospace | size=8\n".join(