Adding a simple script I use to calculate worked hours per day
authorllbatlle@comanegra
Fri, 04 Mar 2011 11:06:11 +0100
changeset 19 39a78ed9bf03
parent 18 8006ca38f6eb
child 20 1567704292af
Adding a simple script I use to calculate worked hours per day
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];
+        }
+    }
+}