% CLOCKCAL.sty - prints a small clockface and calendar day-page % for the current date and time. Uses only regular % CM and LaTeX (line/circle) fonts, but at very % small sizes, so you'll need Metafont to make them. % %\magnification=\magstep5 % uncomment this line to test at big size \font\rings=lcircle10 scaled \magstep2 %\font\rings=circle10 scaled \magstep2 \font\tinyrm=cmdunh10 at1pt \font\small=cmdunh10 at4pt \font\medium=cmdunh10 at8pt \font\minutehand=line10 at6pt \font\hourhand=line10 at4pt \newcount\hours \newcount\minutes \newcount\now \def\gettime{\now=\time \hours=\now \divide\hours by60 \minutes=\now \now=\hours \multiply\now by60 \advance\minutes by-\now} \newdimen\unit \newbox\rbox \newdimen\rvert \newdimen\rhorz \newdimen\hadj \newdimen\vadj \newbox\dialbox \newbox\clockbox \newbox\calbox \newbox\datebox \newbox\timebox \newcount\hour % macro to place numerals at the 12 hours of the clockface % try to accommodate the height and width of the numerals \def\point#1 #2 {\advance\hour by1 % \setbox\rbox=\hbox{{\tinyrm\uppercase\expandafter{\romannumeral\hour}}}% \rvert=\ht\rbox \rhorz=\wd\rbox \divide\rvert by2 \divide\rhorz by2 % \hadj=#1\unit \vadj=#2\unit% \ifnum#1<0\advance\hadj by\rhorz\else\ifnum#1>0 \advance\hadj by-\rhorz\else\fi\fi% \ifnum#2<0\advance\vadj by\rvert\else\ifnum#2>0 \advance\vadj by-\rvert\else\fi\fi% \rlap{\kern\hadj\raise\vadj\box\rbox}} % do the clockface by \rlapping the numerals with a circle \setbox\dialbox=\hbox{\unit=20480sp \point 15 26 \point 26 15 \point 30 0 \point 26 -15 \point 15 -26 \point 0 -30 \point -15 -26 \point -26 -15 \point -30 0 \point -26 15 \point -15 26 \point 0 30 } \setbox\clockbox=\hbox{\rlap{\box\dialbox}% {\kern.5pt\raise.5pt\hbox{{\rings\char'156}}}} % make a box with today's date in it \setbox\datebox=\vbox to15pt{\hsize=15pt\parindent=0pt\medium \centerline{\number\day}\small\kern-6pt \centerline{\ifcase\month\or Jan\or Feb\or Mar \or Apr\or May\or Jun\or Jul\or Aug \or Sep\or Oct\or Nov\or Dec\fi\ \number\year} \vfill} % and pack that into a tear-off calendar block \setbox\calbox=\vbox{\hsize=36pt\parindent=0pt\offinterlineskip% \hbox to\hsize{\hrulefill\hskip16pt}% \hbox to\hsize{\vrule height20pt\hfil\raise1pt\box\datebox \hfil\vrule depth-3pt height20pt\hskip16pt}% \hbox to\hsize{\vrule height3.6pt\hrulefill\vrule height1pt \hskip16pt}\kern-7pt% \hbox to\hsize{{\rings\char'006}\kern-6pt \hbox to20pt{\hrulefill}\kern-6pt{\rings\char'006} \hfil} \vfill} % position the hands \newbox\handbox \newdimen\handwid \newdimen\handht \newcount\hradjust \newcount\hourpos \newbox\hourbox \newbox\minutebox \newdimen\hourwid \newdimen\minwid \newdimen\hourht \newdimen\minht \newbox\rbox % macro to locate a slanted line at the right angle and height \def\hand#1#2#3{%1=position 0-60; 2=font; 3=box \setbox#3=\hbox{{#2 \ifcase#1\vrule height6pt width.1pt% 0 min \or\char'005 % 1 \or\char'003 % 2 \or\char'002 % 3 \or\char'001 % 4 \or\char'042 % 5 \or\char'032 % 6 \or\char'000 % 7 \or\char'045 % 8 \or\char'012 % 9 \or\char'010 % 10 \or\char'041 % 11 \or\char'030 % 12 \or\char'040 % 13 \or\char'050 % 14 \or\vrule width6pt height.1pt% 15 \or\char'150 % 16 \or\char'130 % 17 \or\char'120 % 18 \or\char'110 % 19 \or\char'142 % 20 \or\char'132 % 21 \or\char'100 % 22 \or\char'145 % 23 \or\char'112 % 24 \or\char'101 % 25 \or\char'114 % 26 \or\char'103 % 27 \or\char'104 % 28 \or\char'105 % 29 \or\vrule depth6pt width.1pt% 30 \or\char'005 % 31 \or\char'003 % 32 \or\char'002 % 33 \or\char'001 % 34 \or\char'042 % 35 \or\char'032 % 36 \or\char'000 % 37 \or\char'045 % 38 \or\char'012 % 39 \or\char'010 % 40 \or\char'041 % 41 \or\char'030 % 42 \or\char'040 % 43 \or\char'050 % 44 \or\vrule width6pt height.1pt% 45 \or\char'150 % 46 \or\char'130 % 47 \or\char'120 % 48 \or\char'110 % 49 \or\char'142 % 50 \or\char'132 % 51 \or\char'100 % 52 \or\char'145 % 53 \or\char'112 % 54 \or\char'101 % 55 \or\char'114 % 56 \or\char'103 % 57 \or\char'104 % 58 \or\char'105 % 59 \or\vrule height6pt width.1pt% 60 \fi}}} % grab the current time and break it into minutes and hours \gettime % macros to set hour and minute hands together. % first get rid of 24-hour clock, then adjust hourhand for parts of an hour %\hours=1 \minutes=12 %test \def\hands{\hourpos=\hours\ifnum\hourpos>12\advance\hourpos by-12\fi \multiply\hourpos by5 \hradjust=\minutes \divide\hradjust by12 \advance\hourpos by\hradjust \message{Timestamp: \number\hours.\number\minutes} \hand{\hourpos}{\hourhand}{\hourbox}\hourwid=\wd\hourbox\hourht=\ht\hourbox \hand{\minutes}{\minutehand}{\minutebox}\minwid=\wd\minutebox\minht=\ht\minutebox \setbox\handbox=\hbox{\rlap{\ifnum\hourpos>30\kern-\hourwid\fi% \ifnum\hourpos>15\ifnum\hourpos<45\lower\hourht\fi\fi\box\hourbox}% {\ifnum\minutes>30\kern-\minwid\fi% \ifnum\minutes>15\ifnum\minutes<45\lower\minht\fi\fi\box\minutebox}}} % now paste it all together \def\clockcal{\hands\kern8pt\raise.5ex\hbox{\box\clockbox}\kern-22pt\raise2.5pt\hbox{\box\handbox}\kern9pt\lower14pt\hbox{\box\calbox}}