<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%% Save file as: CALPROG.STY            Source: FILESERV@SHSU.BITNET  
%% Author: Michael Barr &lt;barr@triples.Math.McGill.CA&gt;
%% Original Source: Posted to INFO-TeX@SHSU.edu on Thu, 2 Jan 92 18:33:54 EST
%
%After seeing how complicated a calendar program can be, I was moved to
%fix the one I had been using.  Although I haven't tested it extensively,
%I believe it gives the correct Gregorian dates from whenever the
%Gregorian began (which is different in defferent countries and in Russia
%was not until after 1917) until the year 4000 when a leap year is supposed
%to be omitted.  A better correction would have been to omit leap years
%in all years divisible by 2000 and not by 6000, but this would have
%required immediate agreement and I guess that seemed too difficult.
%
%Obviously, the top line has to be edited to give the desired year.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Start here %%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcount\yearnum \yearnum=1992

\documentstyle{article}
\textwidth 7.05in \oddsidemargin-.255in
\textheight=9in \headheight =0pt \topmargin=0pt\headsep=0pt
\footheight=0pt\footskip=0pt
\pagestyle{empty}\thispagestyle{empty}

\newcount\febdays \febdays=28
\newcount\yearnuma
\newcount\yearnumb
\newcount\firstdate \newcount \lastdate \newcount \datenum

\def\month#1#2#3{\initialdate{#1}{#2}%
\begin{tabular}{|rrrrrrr|}   \hline
\multicolumn{7}{|c|}{#3}\\ \hline
Su&amp;Mo&amp;Tu&amp;We&amp;Th&amp;Fr&amp;Sa\\ \hline
\day{ 1}&amp;\day{ 2}&amp;\day{ 3}&amp;\day{ 4}&amp;\day{ 5}&amp;\day{ 6}&amp;\day{ 7}\\
\day{ 8}&amp;\day{ 9}&amp;\day{10}&amp;\day{11}&amp;\day{12}&amp;\day{13}&amp;\day{14}\\
\day{15}&amp;\day{16}&amp;\day{17}&amp;\day{18}&amp;\day{19}&amp;\day{20}&amp;\day{21}\\
\day{22}&amp;\day{23}&amp;\day{24}&amp;\day{25}&amp;\day{26}&amp;\day{27}&amp;\day{28}\\
\day{29}&amp;\day{30}&amp;\day{31}&amp;\day{32}&amp;\day{33}&amp;\day{34}&amp;\day{35}\\
\day{36}&amp;\day{37}&amp;\day{38}&amp;\day{39}&amp;\day{40}&amp;\day{41}&amp;\day{42}\\ \hline
\end{tabular}\global\advance\firstdate by #2
\ifnum\firstdate&gt;35 \global\advance\firstdate by -35
   \else\global\advance \firstdate by -28 \fi}
\def\day#1{\advance \datenum by#1
   \ifnum\datenum&gt;0 \ifnum\datenum&gt;\lastdate\else\number\datenum \fi\fi}
\def\initialdate#1#2{\datenum=1 \advance\datenum by -#1 \lastdate=#2}
\newcount\xa\newcount\xb\newcount\xc
\newcount\ya\newcount\yb\newcount\yc\newcount\yd
\xa=0 \xb=235 {\multiply \xb by 2 \global\xc=\xb }
\yd=0 \yc=136 {\multiply \yc by 2 \global \yb=\yc }
{\multiply \yc by 3 \global \ya=\yc }

\begin{document}
\font\gross=cminch

\def\setup{\yearnuma=\yearnum{%
\divide\yearnuma by 100
\multiply\yearnuma by 100
\ifnum\yearnum=\yearnuma \divide \yearnum by 100 \fi
\ifodd\yearnum\relax
\else \divide\yearnum by 2
   \ifodd\yearnum\relax
   \else \global\febdays=29
   \fi
\fi
}%
{%
\advance\yearnum by -1
\yearnuma=\yearnum
\divide\yearnuma by 400 \multiply \yearnuma by -400
\advance\yearnuma by \yearnum % \yearnuma=\yearnum mod 400
\firstdate=\yearnuma
\yearnumb=\yearnuma
\divide\yearnumb by 100 \divide\yearnuma by 4
\advance\yearnuma by -\yearnumb % correct leapyear count by centuries
\advance\firstdate by \yearnuma % add number of leapyears
\yearnuma=\firstdate
\divide\yearnuma by 7 \multiply\yearnuma by 7
\advance\firstdate by -\yearnuma % \firstdate = #leapyears mod 7
% Now do final correction for year 0.
\global\firstdate=\ifcase\firstdate2 \or3 \or4 \or5 \or6 \or7 \or1 \fi
}%
}%

\setup
\begin{center}{\gross \number\yearnum }\end{center}
\unitlength.01in
\begin{picture}(705,543)
\put(\xa,\ya){\month{\firstdate}{31}{January}}
\put(\xb,\ya){\month{\firstdate}{\febdays}{February}}
\put(\xc,\ya){\month{\firstdate}{31}{March}}
\put(\xa,\yb){\month{\firstdate}{30}{April}}
\put(\xb,\yb){\month{\firstdate}{31}{May}}
\put(\xc,\yb){\month{\firstdate}{30}{June}}
\put(\xa,\yc){\month{\firstdate}{31}{July}}
\put(\xb,\yc){\month{\firstdate}{31}{August}}
\put(\xc,\yc){\month{\firstdate}{30}{September}}
\put(\xa,\yd){\month{\firstdate}{31}{October}}
\put(\xb,\yd){\month{\firstdate}{30}{November}}
\put(\xc,\yd){\month{\firstdate}{31}{December}}
\end{picture}\newpage

\end{document}}
</pre></body></html>