In section 16.2, the function add_time has sum as local variable. But sum is a built-in function.
This may work but it might be considered as a bad habit to use built-in function names as variable names.
I guess that sum can be replaced, in this particular context, by totaltime (or simply total).