scripts/hores.awk
changeset 19 39a78ed9bf03
child 21 5dababf1cb7d
equal deleted inserted replaced
18:8006ca38f6eb 19:39a78ed9bf03
       
     1 #!/home/llbatlle/.nix-profile/bin/awk -f
       
     2 #
       
     3 # Entrada: tt -t
       
     4 #
       
     5 # Distingeix 'fora' i 'dinar' com a coses que no són de la feina
       
     6 
       
     7 BEGIN {
       
     8     fora="fora";
       
     9     ignora="dinar";
       
    10     FS=" "
       
    11 }
       
    12 
       
    13 {
       
    14     daystring = substr($3, 2);
       
    15     work = $2;
       
    16 
       
    17     if (work == fora)
       
    18     {
       
    19         hores = int(accumtime / 3600);
       
    20         minuts = int((accumtime  - hores*3600) / 60);
       
    21         segons = int(accumtime  - hores*3600 - minuts*60);
       
    22 
       
    23         plegant = substr($4, 1, length($4)-1);
       
    24         printf "%s: %02i:%02i:%02i (plegant a les %s)\n",
       
    25             daystring, hores, minuts, segons, plegant;
       
    26         accumtime = 0;
       
    27     }
       
    28     else
       
    29     {
       
    30         if (work != ignora)
       
    31         {
       
    32             split($1, time, ":");
       
    33 
       
    34             accumtime += time[1]*3600 + time[2]*60 + time[3];
       
    35         }
       
    36     }
       
    37 }