% planner.sty - a modification of calendar.sty to produce %
% a "planner" with one month per page - rags - 11 May 92  %
 
\typeout{Be sure to print in landscape mode}
 
% calendar.sty allows you to make a one page Gregorian calendar for any
% year.  It does not give the correct Julian dates for the years before
% the Gregorian calendar was introduced.  The use is simple.  Just say
% \year{<year>}.
%
% Copyright, 1989 Michael Barr May be freely used by anyone not an
% employee of a telephone company.  It may be freely distributed as long
% as this notice is included.
 
\newcommand{\gap}{\rule[-2.50cm]{0cm}{2.75cm}\rule{2.70cm}{0cm}}
\font\headfont=cmr17 scaled \magstep4
 
\textheight10.5in \headsep 0in \headheight0in \topmargin-.70in
\textwidth 10.5in \oddsidemargin-.740in
\pagestyle{empty}\thispagestyle{empty}
 
\def\month#1#2#3{\initialdate{#1}{#2}%
\begin{tabular}{||r|r|r|r|r|r|r||}   \hline
\multicolumn{7}{||c||}{{\rule[-0.3cm]{0cm}{1.5cm}\headfont #3~\thisyear}}\\ \hline
Su&Mo&Tu&We&Th&Fr&Sa\\ \hline
\day{ 1}&\day{ 2}&\day{ 3}&\day{ 4}&\day{ 5}&\day{ 6}&\day{ 7}\\  \hline
\day{ 8}&\day{ 9}&\day{10}&\day{11}&\day{12}&\day{13}&\day{14}\\  \hline
\day{15}&\day{16}&\day{17}&\day{18}&\day{19}&\day{20}&\day{21}\\  \hline
\day{22}&\day{23}&\day{24}&\day{25}&\day{26}&\day{27}&\day{28}\\  \hline
\day{29}&\day{30}&\day{31}&\day{32}&\day{33}&\day{34}&\day{35}\\  \hline
\day{36}&\day{37}&\day{38}&\day{39}&\day{40}&\day{41}&\day{42}\\ \hline
\end{tabular}\global\advance\firstdate by #2
\ifnum\firstdate>35 \global\advance\firstdate by -35
   \else\global\advance \firstdate by -28 \fi}
\def\day#1{\advance \date by#1
   \ifnum\date>0 \ifnum\date>\lastdate\else\gap\number\date \fi\fi}
\newcount\firstdate \newcount \lastdate \newcount \date
\def\initialdate#1#2{\date=1 \advance\date by -#1 \lastdate=#2}
 
 
\newif\ifleap
\newcount\yearnum
 
\def\year#1{\Large
\yearnum=#1
\newcommand{\thisyear}{#1}
\leaptrue
{\ifodd \yearnum \global\leapfalse \else \divide\yearnum by 2
     \ifodd\yearnum \global\leapfalse\fi\fi}
{\ifleap \divide\yearnum by 100 \multiply\yearnum by 100
     \ifnum\yearnum=#1 \divide\yearnum by 100 \ifodd
       \yearnum\global\leapfalse\else
     \divide\yearnum by 2 \ifodd\yearnum\global\leapfalse\fi\fi\fi\fi}
\setfirstdate
 \month{\firstdate}{31}{January}   \newpage
 \ifleap \month{\firstdate}{29}{February}   \newpage
 \else \month{\firstdate}{28}{February}\newpage \fi
 \month{\firstdate}{31}{March}     \newpage
 \month{\firstdate}{30}{April}     \newpage
 \month{\firstdate}{31}{May}       \newpage
 \month{\firstdate}{30}{June}      \newpage
 \month{\firstdate}{31}{July}      \newpage
 \month{\firstdate}{31}{August}    \newpage
 \month{\firstdate}{30}{September} \newpage
 \month{\firstdate}{31}{October}   \newpage
 \month{\firstdate}{30}{November}  \newpage
 \month{\firstdate}{31}{December}
}
 
\newcount\tempa \newcount\tempb \newcount\tempc
 
\def\mod(#1,#2,#3){%
\tempa#1 \tempb\tempa
\divide\tempa by #2  \multiply\tempa by #2
\advance\tempb by -\tempa \global#3=\tempb}
 
\def\setfirstdate{%
\mod(\yearnum,400,\tempc)
\ifnum\tempc>0 \global\advance\tempc by -1\else\tempc=4 \fi
\firstdate=2 \advance\firstdate by \tempc
\divide\tempc by 4 \advance \firstdate by \tempc
\divide\tempc by 25 \advance\firstdate by -\tempc
\tempc=\firstdate \mod(\tempc,7,\firstdate)
\ifnum\firstdate=0 \global\firstdate=7 \fi}
 
% Here's a sample file to print out the 1992 calendar:
% \documentstyle[planner]{article}
% \begin{document}
% \year{1992}
% \end{document}
 
