commit 22a95642a232410bf4d8cb7f5f4bf9d695eb6fb2
parent 534354841b3e275a5bd9398844430eefe13212be
Author: tongong <tongong@gmx.net>
Date: Sat, 26 Jun 2021 16:06:20 +0200
only show one week
Diffstat:
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/timetracker-report b/timetracker-report
@@ -1,17 +1,9 @@
#!/usr/bin/env python3
import os
-from datetime import datetime
+from datetime import datetime, timedelta
from math import floor
import subprocess
-# TODO
-# - only show one week or so
-# - add more graphs
-# - average daily time for week/month/year
-# - total time per program
-# - check if termgraph is installed
-# - add commandline arguments to just look at specific date or specific program
-
# helper functions
def filelocation():
if (os.getenv("XDG_DATA_HOME")):
@@ -71,20 +63,22 @@ for line in datafile:
dayRef[program] = ptime
# graphs
-printHeading("# past days")
+printHeading("# past week")
tgIn = "" # termgraph input
-for day in days:
+for i in range(7):
+ day = (datetime.today() + timedelta(days=i-6)).strftime("%Y-%m-%d")
daySum = 0
- for program in days[day]:
- if program != "slock" and program != "standby":
- daySum += days[day][program]
+ if day in days:
+ for program in days[day]:
+ if program != "slock" and program != "standby":
+ daySum += days[day][program]
tgIn += day + " " + timestring(daySum).rjust(5, " ") + "," + \
str(daySum) + "\n"
print(runExternal(["termgraph", "--label-before", "--no-values"], tgIn)[1:-2])
-print()
-today = datetime.fromtimestamp(int(parts[0])).strftime("%Y-%m-%d")
+today = datetime.today().strftime("%Y-%m-%d")
if today in days:
+ print()
printHeading("# today")
tgIn = "" # termgraph input
for program in sorted(days[today], key=lambda x: days[today][x],