[OS X TeX] datetime

Robert Bruner rrb at math.wayne.edu
Thu Jul 13 23:16:19 CEST 2006


Jack Kuipers asked:

> Dear: Whoever, (Knowledgable Ones)
> In \documentclass[twosided,12pt]{book} how can I record the date and 
> the time.

Dear Jack,

I have used a little file, timestamp.tex (appended), which I found some
time ago.  The \date{\today} (when unmodified by timestamp.tex) adds a
footnote ``Received by the editors July 13, 2006'' to the titlepage
material, about 3 pages in when using the documentclass for Amer Math
Soc Memoirs.  Usually, I want the date right out front when I am in the
thick of editing, for 'version control'.  For that, i use

    
    \input{timestamp.tex}
    
    blah blah blah
    
    \begin{document}
    \date{\today}      %% I will want this eventually
    \title{Wonderful Document \\
    (\timestamp)}      %% But I want this one while editing
    \author{    blah blah blah
    
    
    \maketitle
    
and then I have the date and time right at the front:

                Wonderful Document
                (2006-07-13 17:06)

as well as the footnote about the editors hidden at the bottom
of the page containing the abstract.

FWIW,

Bob Bruner



%% I saved this as timestamp.tex
%% -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

% today.tex: Macro to print today's date
%--
% Author: John W. Shipman, NM Tech Computer Center,
%   Socorro, NM 87801; john at nmt.edu
%--
% EXPORTED FUNCTIONS:
%   \today: Outputs today's date as ``yyyy-mm-dd''
%   \now: Outputs the current time as ``hh:dd''
%   \timestamp: \today, plus one space, plus \now
%--
\newcount\minute	% Current minute within the hour
\newcount\hour		% Current hour (24-hour type)
\newcount\hourMins  % Temporary for taking hour modulo 60
%
% - - -   \ n o w   - - -
%
\def\now%
{% Displays today's time as ``hh:mm''
%  The \time macro gives the minutes since midnight.  Compute
%  the whole hours by dividing this by 60, then find the
%  minute by effectively taking the minutes modulo 60.
%
  \minute=\time    % Number of minutes since midnight
  \hour=\time \divide \hour by 60 % Get hours
  \hourMins=\hour \multiply\hourMins by 60
  \advance\minute by -\hourMins % Hours modulo 60
%
  \zeroPadTwo{\the\hour}:\zeroPadTwo{\the\minute}%
}% --- \now ---
%
% - - -   \ t i m e s t a m p   - - -
%
\def\timestamp%
{% Displays ``yyyy-mm-dd hh:mm''
  \today\ \now
}% --- \timestamp ---
%
% - - -   \ t o d a y   - - -
%
\def\today%
{% Displays today's date and time as ``yyyy-mm-dd hh:mm''
  \the\year-\zeroPadTwo{\the\month}-\zeroPadTwo{\the\day}%
}% --- \today ---
%
% - - -   z e r o P a d T w o   - - -
%
\def\zeroPadTwo#1%
{% Left zero pad of the argument to 2 digits.  The argument
%  should be a number between 1 and 99.  This macro outputs
%  a `0' if the argument is less than ten, then it outputs
%  the argument.
%
  \ifnum #1<10 0\fi    % Conditionally output a zero
  #1%    Then output the argument
}% --- \zeroPadTwo ---

%%  And this is today (\today) and now (\now) and
%%  a timestamp (\timestamp).

%% -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/




More information about the macostex-archives mailing list