I understand that trying to have a "loop function" like \foreach loop sounds like a paradox but I'll try to explain what I mean. Recently, I've asked a question about automatising the creation of hours in a timeline, in order to have them increase, i.e. 00:00, 01:00, 02:00 and so on.
I forgot to mention something there and the problem came out when I was playing with the options. Now for reference this is the part of the code that controlled the hours:
\newcommand*{\MaxNumber}{17}%
\begin{document}
\begin{tikzpicture}
%draw horizontal line
\draw[|->, -latex] (0,0) -- (\MaxNumber,0);
\draw[-, dashed] (-1,0) -- (0,0);
%draw hours
\foreach \x in {0,...,\MaxNumber} {%
\draw (\x,0) node[below=7pt,anchor=east,xshift=0,rotate=45] {$\x\colon 00$};
\draw[] (\x,-0.1) -- (\x,0.1);
}
If I set the \MaxNumber to 23, the hours would draw each hour using the 24-Hour clock.
But if I set it to, say, 50, the displayed hours would not restart from 00:00, i.e. midnight, instead they'd keep increasing up to 50:00. But since this is a timeline, I'd like the \foreach to restart each time it reaches 23:00, since 24:00 and 00:00 are the same hour.
I've tried tweaking it and searching both this site and internet, but I'm not that expert yet to understand what I could work on. I expect there to be many ways to do this so I'd like to know, what would be the most appropriate way to do it?

\colonis wrong; it should simply be{\ModValue:00}. (2) More importantly,+1should be removed. – egreg Oct 08 '12 at 23:50\colonleaves a space that:doesn't. – egreg Oct 08 '12 at 23:5300:00. I think we never actually use24:00(and I think nobody does) since the hour after is01:00and it would be inconsistent to have24:00-01:00. :D Thanks for the great effort! – Alenanno Oct 09 '12 at 09:40