In continuation of the post, I try to make the following (simplified) code to work.
- \timedelta uses 2 arguments.
- Using a \gdef as the first argument is Ok.
- Using a \gdef as the second argument is Nok.
I cannot go away from the exception
21: Paragraph ended before \timedelta@i was complete. []
\documentclass{article}
\makeatletter
\newcommand{\timedelta}[2]{\romannumeral0\timedelta@i#1:#2:}%
\def\timedelta@i #1:#2:#3:#4:%
{\expandafter\timedelta@ii\the\numexpr#3*60+#4-#1*60-#2.}%
\def\timedelta@ii#1{\expandafter\timedelta@iii\the\numexpr
\if-#11440\fi #1}%
\def\timedelta@iii#1.{\expandafter\timedelta@iv\the\numexpr
(#1 + 30)/60 -1.#1.}%
\def\timedelta@iv #1.#2.{\expandafter\timedelta@v\the\numexpr
100+#2-60*#1\expandafter.\the\numexpr100+#1.}
\def\timedelta@v 1#1.1#2.{ #2:#1}
\makeatother
\begin{document}
\gdef\routeStart{01:27}
\expandafter\timedelta\expandafter{\routeStart}{01:27}% ok
\gdef\routeStop{01:27}
\expandafter\timedelta{16:03}\expandafter{\routeStop}% nok -> Paragraph ended before \timedelta@i was complete.
\end{document}
My Edits after the first answers
How to "expand" the two arguments? Thx!
\timedelta{\routeStart}{\routeStop}

\expandafter\timedelta{applies expandafter to a{but that is not an expandable token – David Carlisle Nov 08 '17 at 18:35\gdefas argument, but a macro (here\routeStartor\routeStop). – Skillmon Nov 08 '17 at 19:24\timedeltaexpand automatically its two arguments. I have now added this to this initial answer of your post. As per the question here, my answer defines\timedeltaOOand\timedeltaXXwhich both would work with{\routeStart}{\routeStop}arguments. But simpler to use the enhanced\timedeltanow there – Nov 08 '17 at 22:14