[texhax] tip: time-am-pm

Ron RJF Fehd ron.fehd.macro.maven at gmail.com
Mon Jul 11 22:52:28 CEST 2016

I wanted to add a time-stamp to a document
and found that \time contains the number of minutes since midnight.

The TeX Reference Manual, by David Bausum
contains a function to format time to civilian time

%%  name: \texmf-local\tex\latex\local\format-time-am-pm.sty
%%description: format time as minutes since midnight
%%             to hh:mm am|pm
%%    purpose: provide time-stamp
%% usage:
%date-time-stamp: \today, \timeAMPM{\the\time}
%%source: TeX Reference Manual, by David Bausum
%%        time, civilian, pg 290:291
%%        for military time see ifnum, pg 144
\def\timeAMPM#1% expected value=\the\time
  \divide  \count20 by  60
  \multiply\count21 by -60
  \advance \count22 by \count21
  \ifnum\count20<12\def\textAmPm{ am}
     \else         \def\textAmPm{ pm}
     \advance\count20 by -12
  \ifnum\count22<10 0\fi

Ron Fehd  Atlanta GA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texhax/attachments/20160711/cd4dbad9/attachment.html>

More information about the texhax mailing list