I am generating a table automated with a macro based on my other question (Time calculation with spreadtab).
There will be three (maybe four, maybe n - don’t know if the answer to this question can easily be implemented generic) meta-types of entries (for the example let’s say they are A, B, C):
So my table would look like this:
So I want to generate a pie chart based on the duration times, e.g. for the example above:
A: 00:30
B: 00:30
C: 00:10
Therefore I need to add the durations based on a meta-tag given to a specific row. Not part of the question, but to get an overall look at my problem: My final goal is to pass these values to something like described here: (Package for pie charts, e.g. this answer).
So how do I do this meta-tag based adding (and dividing through the sum), and storing the values? MWE:
\documentclass{article}
%% time calc
\def\InitialStartTime{09:00}
\newcount\hours
\newcount\minutes
\def\gettime#1:#2\relax#3#4{\def#3{#1}\def#4{#2}}
\newcommand{\add}[2]{%
\expandafter\gettime#1\relax{\hrs}{\mins}
\expandafter\gettime#2\relax{\addhrs}{\addmins}%
\hours=\hrs\relax
\advance\hours by \addhrs\relax
\minutes=\mins\relax
\advance\minutes by \addmins\relax
\ifnum\minutes>59\relax
\advance\minutes by -60\relax
\advance\hours by 1\relax
\else
\ifnum\minutes<0\relax
\advance\minutes by 60\relax
\advance\hours by -1\relax
\fi
\fi
\ifnum\hours>23\relax
\advance\hours by -24\relax
\else
\ifnum\hours<0\relax
\advance\hours by 24\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 & duration & starttime & endtime\\
\hline
One & \newStartTime{00:20} %adding the meta-data of this row?
Two & \newStartTime{00:30} %adding the meta-data of this row?
Three & \newStartTime{00:10} %adding the meta-data of this row?
Four & \newStartTime{00:10} %adding the meta-data of this row?
\end{tabular}
%here comes the wished output
A: %\timeOfMeta{A}
B: %\timeOfMeta{B}
C: %\timeOfMeta{C}
%
\end{document}


\newtiming{<tag>}{<starttime>}{<endtime>}although we can spare the<starttime>part if all rows are in order. The macro would create the remaining cells in the row (printing or not the tag, depending on what one wants) and accumulate total times for each tag, for later use. – Sep 10 '16 at 18:40