The \FpEval{}{} function which can be used to do computations, and store the result in a variable, in latex. For details, kindly see How can I sum two values and store the result in other variable? .
The package tdclock contains a macro called \tdhours which can display the current system time. For details, kindly see this pdf .
I would like to read the hour from \tdhours and perform some simple computation with it. For Ex, I want to do read the hour from \tdhours and subtract it from 24, and display the time left for midnight. I tried this naive thing, which does not work:
\documentclass{article}
\usepackage{fp,tdclock}
\begin{document}
\initclock
Current time is \tdhours hours .
\FPeval{\timeLeftForMidN}{clip(24-\tdhours)}
There is \timeLeftForMidN hours more for midnight.
\end{document}
This gives the error message:
! Illegal parameter number in definition of \FP@tmp.
<to be read again>
1
l.8 \FPeval{\timeLeftForMidN}{clip(24-\tdhours)}
?
! Illegal parameter number in definition of \FP@tmp.
<to be read again>
2
l.8 \FPeval{\timeLeftForMidN}{clip(24-\tdhours)}
?
! Illegal parameter number in definition of \FP@tmp.
<to be read again>
3
l.8 \FPeval{\timeLeftForMidN}{clip(24-\tdhours)}
?
! Undefined control sequence.
\clock@temp ...\def \clock@tempa ##1,##2,##3\@nil
{##1 ##2 ##3}\extractcolor...
l.8 \FPeval{\timeLeftForMidN}{clip(24-\tdhours)}
Just to emphasize the difference between what I am saying and a question that already exists in stack-exchange called How to make time-dependent code? : There the question is about making the pdf text compilation-time dependent. It is equivalent to manually adding in the current time each time the pdflatex file is compiled. The datetime package is the solution in that case.
However, in my case, I need a pdf that is dependent on the time at which the pdf file is being viewed.
\tdhoursis a set of instructions for printing the hour, not simply the current hour. – egreg Mar 11 '13 at 23:20\tdhoursdoesn't hold the value of the hours but intiates a JS textfield which is populated by Acrobat's javascript abilities. Hence it's not possible in the way you have proposed. – percusse Mar 11 '13 at 23:21