Differences between current version and predecessor to the previous major change of LatexExample.
Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 3 | Last edited on Wednesday, September 17, 2008 10:46:25 pm | by JimCheetham | |
Older page: | version 2 | Last edited on Saturday, May 7, 2005 8:49:43 am | by AristotlePagaltzis | Revert |
@@ -89,4 +89,48 @@
<texc.pro>. [1] [1] [1] [2]
</verbatim>
You can now view these with a PostScript or [PDF] viewer, such as GhostView or AcrobatReader.
+
+----
+
+!!! Dates and times
+
+The ~LaTeX command <code>\today</code> prints the date that the document is processed in a format determined by your language settings. There is a time record, but this gives the number of minutes since midnight and this isn't particularly useful in itself.
+
+!! Solutions
+
+There are a number of ways to include the current time in your document. In order of potential usefulness they are:
+
+! Using the <code>datetime</code> package
+
+The [datetime|http://www.ctan.org/tex-archive/macros/latex/contrib/datetime/] package provides commands for not only easily reformatting the date but for printing the time in several formats.
+
+! Inserting your own time calculation code in the document
+
+The most satisfying approach for a coder. Programming in ~TeX is an interesting challenge. The following code (included in a ~LaTeX file preamble) can be used to print the time in 24-hour format:
+
+<pre>
+\newcount\c@HOUR
+\newcount\c@FINALHOUR
+\newcount\c@MINUTE
+\newcount\c@HOURSINMINUTES
+\newcount\@INTVAL
+
+\newcommand{\twodigit}~[1]{\@INTVAL=#1\relax\ifnum\@INTVAL<10 0\fi\the\@INTVAL}
+
+\c@FINALHOUR=\time\divide\c@FINALHOUR by 60\relax
+\c@HOUR=\time\divide\c@HOUR by 60\relax
+\c@HOURSINMINUTES=\c@HOUR\multiply\c@HOURSINMINUTES by 60\relax
+\c@MINUTE=\time\advance\c@MINUTE by -\c@HOURSINMINUTES\relax
+\def\THEHOUR{\the\c@FINALHOUR}
+\def\THEMINUTES{\the\c@MINUTE}
+
+% time in HH:MM (24 hour clock)
+\newcommand\rightnow{\twodigit{\THEHOUR}:\twodigit{\THEMINUTES}}
+</pre>
+
+Anywhere in the document <code>\rightnow</code> may be used to print the time the document was assembled (or more correctly, the time on the system clock when the document assembly began).
+
+! Modifying the source <code>.tex</code> file when processing the file.
+
+Calling an editor like <code>awk</code> or <code>sed</code> to pre-process the source file is potentially popular with command-line geeks, but is rather clunky and has the feeling of a kludge about it. Not recommended.