scripts/hores.awk
author llbatlle@comanegra
Fri, 04 Mar 2011 11:06:11 +0100
changeset 19 39a78ed9bf03
child 21 5dababf1cb7d
permissions -rwxr-xr-x
Adding a simple script I use to calculate worked hours per day

#!/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];
        }
    }
}