siemsen@sol.usc.edu (Pete Siemsen) (04/27/91)
A user here asked for a way to insert the current time and date into his LaTeX files. I found a macro in "TeX for the Impatient" that does the job nicely, and the user went away happy. Then he tried using the macro in his page headings, where it only works partially. Here's a sample file the demonstrates the problem. In the heading, the date is fine but the time comes out as "0:0". I'm by no means experienced enough to understand why. Help! \documentstyle[11pt]{article} %---------------------------------------------------------------------------- \def\monthname{% \ifcase\month \or January \or February \or March \or April% \or May \or June \or July \or August% \or September\or October \or November\or December% \fi}% \def\timestring{\begingroup \count0 = \time \divide\count0 by 60 \count2 = \count0 % The hour. \count4 = \time \multiply\count0 by 60 \advance\count4 by -\count0 % The minute. \ifnum\count4<10 \toks1 = {0} % Get a leading zero. \else \toks1 = {}% \fi \ifnum\count2<12 \toks0 = {a.m.}% \else \toks0 = {p.m.}% \advance\count2 by -12 \fi \ifnum\count2=0 \count2 = 12 \fi % Make midnight '12'. \number\count2:\the\toks1 \number\count4 \thinspace \the\toks0 \endgroup}% \def\timestamp{\number\day\space\monthname\space \number\year\quad\timestring}% %---------------------------------------------------------------------------- \pagestyle{myheadings} \markright{test heading: the time is \timestamp} \begin{document} test line, page one, the time is \timestamp \pagebreak test line, page two, the time is \timestamp \pagebreak \end{document} -- Pete Siemsen Pete Siemsen siemsen@usc.edu University of Southern California 645 Ohio Ave. #302 (213) 740-7391 (w) 1020 West Jefferson Blvd. Long Beach, CA 90814 (213) 433-3059 (h) Los Angeles, CA 90089-0251
panos@db.toronto.edu (Panos Economopoulos) (04/28/91)
siemsen@sol.usc.edu (Pete Siemsen) writes: >A user here asked for a way to insert the current time and date into >his LaTeX files. I found a macro in "TeX for the Impatient" that does >the job nicely, and the user went away happy. Then he tried using the >macro in his page headings, where it only works partially. >Here's a sample file the demonstrates the problem. In the heading, >the date is fine but the time comes out as "0:0". I'm by no means I cannot help you with the macro you just posted. As far as the date is concerned, LaTeX has a \today macro. Regarding the time of the day, I use in page headers the following \hhmm macro, found in in our ``Local Guide to LaTeX''. The specific file (page layout) seems to have originally been posted/mailed by Nelson Beebe at U. of Utah. It does handle times like 3:02. % ---------------------------------------------------------------------- % % TIME OF DAY % \newcount\hh \newcount\mm \mm=\time \hh=\time \divide\hh by 60 \divide\mm by 60 \multiply\mm by 60 \mm=-\mm \advance\mm by \time \def\hhmm{\number\hh:\ifnum\mm<10{}0\fi\number\mm} % ---------------------------------------------------------------------- Panos Economopoulos -- panos@csri.toronto.edu (ARPA/CSNet) University of Toronto {uunet, ...}!utcsri!panos (UUCP) panos@csri.utoronto (Bitnet) panos@csri.toronto.cdn (CDNnet/EAN/X.400)