-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtiro_week_summary
More file actions
executable file
·37 lines (33 loc) · 879 Bytes
/
tiro_week_summary
File metadata and controls
executable file
·37 lines (33 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
set -e
set -u
echo "Using files:"
find . -maxdepth 2 -type f -iname 'plan*' | sort
find . -maxdepth 2 -type f -iname 'plan*' -print0 | xargs -0 -r grep -h '^@.*:.*$' | tr ':' ' ' | awk '{print $2,$1}' | gawk '
{ time[$NF] += $1 * 60 + $2}
function q(a,b){
return (a - (a%b)) / b
}
function comp_hours(m){
return q(m, 60)
}
function comp_minutes(m){
return m - q(m,60) * 60
}
END {
for(activity in time){
hours = int(time[activity] / 60)
minutes = time[activity] - hours * 60
if(minutes < 10)
zero = "0"
else
zero = ""
print "Time spent on " activity ": " hours "h" zero minutes
if(activity == "@work"){
hours_left = ENVIRON["WORK_HOURS"] - comp_hours(time[activity])
if(hours_left > 0)
print "Time left on " activity ": " hours_left "h" comp_minutes(ENVIRON["WORK_HOURS"]*60 - time[activity])
}
}
}
'