I come from this question: How can I automatically calculate sums in a LaTeX table?

I want to do the same but with "timing" calculations. So my example would look like this:

\documentclass{article}
\begin{document}
@ a    & @ xyz      & @ duration      & @ starttime & @ endtime \\
@ a1   & 5          & 00:03           & 00:00       & add(c2, d2) \\
@ a2   & 9          & 00:01           & (automatically value of previous endtime)       & add(c3, d3) \\
% and so on
\end{document}


I have to do do dozens of These which will change from time to time, and i only want to change the Duration and every other will be calculated.

I would stronly prefere a solution without luaTeX.

Based on Time calculations:

\documentclass{article}

\usepackage{}

\def\InitialStartTime{09:00}

\newcount\hours
\newcount\minutes

\def\gettime#1:#2\relax#3#4{\def#3{#1}\def#4{#2}}

\expandafter\gettime#1\relax{\hrs}{\mins}
\hours=\hrs\relax
\minutes=\mins\relax
\ifnum\minutes>59\relax
\else
\ifnum\minutes<0\relax
\fi
\fi
\ifnum\hours>23\relax
\else
\ifnum\hours<0\relax
\fi
\fi
\ifnum\minutes<10\relax
\ifnum\hours<10\relax
\xdef#1{0\number\hours:0\number\minutes}%
\else
\xdef#1{\number\hours:0\number\minutes}%
\fi
\else
\ifnum\hours<10\relax
\xdef#1{0\number\hours:\number\minutes}%
\else
\xdef#1{\number\hours:\number\minutes}%
\fi
\fi
}

\newcommand\newStartTime[1]{#1 h~~ & \startTime{} & \add\startTime{#1}\startTime\\}

\begin{document}
\xdef\startTime{\InitialStartTime}
\begin{tabular}{lllll}
a  & xyz & duration & starttime & endtime\\
\hline
a1 & 5   & \newStartTime{00:03}
a2 & 9   & \newStartTime{00:01}
\end{tabular}
\end{document}


• Very nice! Could you expand the example so that there is always the formittag xx:xx. If I use your example i get for the first starttime xx:xx and in the following lines: x:xx - is this fixable? – user69453 Jul 26 '16 at 18:43
• @user69453 yes, it's fixable. See the updated code. – samcarter_is_at_topanswers.xyz Jul 26 '16 at 19:36