-
Hi, I'm trying to evaluate if timewarrior would fit my use case. Let' say I work 40 hours/week no matter how many every day. What I'd like to see in a weekly report is the amount of hours left to reach that target. Obviously I can just see the weekly report and compare the numbers, but it would be just nicer if on friday I can know when I have to stop working instead of doing the calculations myself. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Hi @lauft, I'm pinging just in case, don't see that much activity around discussions here 🙂 |
Beta Was this translation helpful? Give feedback.
-
while it's not pretty, you could do something like:
to find time time you'd have to stop to hit 40H since week start. Remove the outer "task calc" to get the duration remaining from now instead of the time that will be... |
Beta Was this translation helpful? Give feedback.
-
I would recommend to create a custom report for this. Such a report can be a script or compiled program, it only needs to be able to consume the format of Timewarrior's extension API (see https://timewarrior.net/docs/api/#input-format). A very simple example for your use case would be the following script (this uses the Python package timew-report, which offers some useful functions for parsing, so you can concentrate on the report itself. See also below): #!/usr/bin/env python3
import datetime
import sys
from timewreport.parser import TimeWarriorParser
# parse Timewarrior output from stdin
parser = TimeWarriorParser(sys.stdin)
total_budget = datetime.timedelta(hours=40) # initialize budget with 40h
total_time = datetime.timedelta() # initialize total duration
# iterate through the intervals...
for interval in parser.get_intervals():
total_time += interval.get_duration() # ... and add up durations
budget_diff = total_budget - total_time # calculate time difference
# Print out time budget message (proper time formatting left out for brevity)
print("{}s of {}s to go...".format(budget_diff.total_seconds(), total_budget.total_seconds())) Store it as You can then call the report like below and it will print out how many of your 144.000 seconds (=40h) you will have left: $ timew budget :week
50760.0s of 144000.0s to go... Some final notes:Timewarrior's The example script above requires you to install the Python package $ pip install timew-report If you do not want to "pollute" your Python environment, you can also create a virtual environment and install it there: $ python -m venv /path/to/your/venv # create the virtual environment 'venv'
$ /path/to/your/venv/bin/pip install timew-report # use pip from venv to install the package If you change the first line of #!/path/to/your/venv/bin/python
... it will run in this isolated environment. |
Beta Was this translation helpful? Give feedback.
I would recommend to create a custom report for this. Such a report can be a script or compiled program, it only needs to be able to consume the format of Timewarrior's extension API (see https://timewarrior.net/docs/api/#input-format).
A very simple example for your use case would be the following script (this uses the Python package timew-report, which offers some useful functions for parsing, so you can concentrate on the report itself. See also below):