try this with GNU awk, I haven't checked the math:
$ cat tst.awk
NR<3{ next }
{
start = mktime(gensub(/(....)(..)(..).(..)(..)(..)/,"\\1 \\2 \\3 \\4 \\5 \\6","",$2))
end = mktime(gensub(/(....)(..)(..).(..)(..)(..)/,"\\1 \\2 \\3 \\4 \\5 \\6","",$3))
dur[$1] += end - start
}
END {
for (task in dur)
print task, dur[task]
}
$
$ gawk -f tst.awk file
task1 3471
task2 6980
The outputs in seconds, massage to suit...
EDIT: to get the total duration of all tasks that satisfy some RE would be:
NR<3{ next }
$1 ~ re {
start = mktime(gensub(/(....)(..)(..).(..)(..)(..)/,"\\1 \\2 \\3 \\4 \\5 \\6","",$2))
end = mktime(gensub(/(....)(..)(..).(..)(..)(..)/,"\\1 \\2 \\3 \\4 \\5 \\6","",$3))
dur += end - start
}
END {
print dur
}
$ gawk -v re='<specify your RE>' -f tst.awk file
STEVE'S EDIT:
This answer is almost there. I've made a few small changes incorporating the information from the comments above/below. You can change the regex as required, for example:
awk '/task/ { a = "(....)(..)(..).(..)(..)(..)"; b = "\\1 \\2 \\3 \\4 \\5 \\6"; t += mktime(gensub(a, b, "", $NF)) - mktime(gensub(a, b, "", $(NF-1))) } END { print t }' file
Results:
10451