# HG changeset patch # User llbatlle@comanegra # Date 1299233171 -3600 # Node ID 39a78ed9bf036e0b66a1c803c18436820b930bbd # Parent 8006ca38f6eba2ad01c7e615e42633b2734fd3ef Adding a simple script I use to calculate worked hours per day diff -r 8006ca38f6eb -r 39a78ed9bf03 scripts/hores.awk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/hores.awk Fri Mar 04 11:06:11 2011 +0100 @@ -0,0 +1,37 @@ +#!/home/llbatlle/.nix-profile/bin/awk -f +# +# Entrada: tt -t +# +# Distingeix 'fora' i 'dinar' com a coses que no són de la feina + +BEGIN { + fora="fora"; + ignora="dinar"; + FS=" " +} + +{ + daystring = substr($3, 2); + work = $2; + + if (work == fora) + { + hores = int(accumtime / 3600); + minuts = int((accumtime - hores*3600) / 60); + segons = int(accumtime - hores*3600 - minuts*60); + + plegant = substr($4, 1, length($4)-1); + printf "%s: %02i:%02i:%02i (plegant a les %s)\n", + daystring, hores, minuts, segons, plegant; + accumtime = 0; + } + else + { + if (work != ignora) + { + split($1, time, ":"); + + accumtime += time[1]*3600 + time[2]*60 + time[3]; + } + } +}