geoffo@elecvax.eecs.unsw.oz (Geoff Oakley) (02/17/88)
A while ago I posted a TeX program which automatically formatted a calender/diary for any given year onto two pages. John Barlow has cleaned up its limited range of years, increasing the range to include any year from 0 to 2400 AD. His letter to me and program follow. geoff oakley -=+##+=--=+##+=--=+##+=--=+##+=--=+##+=--=+##+=--=+##+=--=+##+=--=+##+=- Hello. I have been playing with your diary/calendar TeX program (the one you sent to the news network a while back) I have altered it to handle dates outside of 1980 - 1999. It uses both Julian and Gregorian Calendars (for the appropriate years) with the option of using the Gregorian calendar from 1752 (GB & U.S.A) or 1582 (Europe). Distribute it around the net if you like (I'm having problems sending news). I find it now very useful. It appears to be correct. I'll sendfile it to you. Best regards, John Barlow. jdb = John Barlow, Automated Reasoning Project, Australian National University mail = I-Block, PO Box 4, Canberra, 2601, Australia. JANET=arp.anu.oz!jdb@ukc ACSnet/CSNET=jdb@arp.anu.oz ARPA/Internet=jdb%arp.anu.oz@uunet.uu.net UUCP = {uunet,hplabs,ubc-vision,ukc,mcvax}!munnari!arp.anu.oz!jdb -=+##+=--=+##+=--=+##+=--=+##+=--=+##+=--=+##+=--=+##+=--=+##+=--=+##+=- % Altered by John Barlow , 11/2/88. % DEFAULT (option denoted by comments starting "%GB&USA" % - follows julian calendar from 0 AD to 1752 AD % - changover during September 1752 , going 1, 2, 14, 15 ... % - follows British and American gregorian calendar from 1752 AD till % They deviate from the current calendar. (at least 2400 AD) % OPTION (option denoted by comments starting "%GREG" % - follows julian calendar from 0 AD to 1582 AD % - changover during October 1582 , going 1, 2, 3, 4, 15, 16 ... % - follows Pope Gregory XIII (gregorian) calendar from 1582 AD till % They deviate from the current calendar. (at least 2400 AD) % To swap between options - I suggest leaving in all commented lines, and % just replacing the existing (uncommented) optional code with the other % option. % %John Barlow Telephone: %Automated Reasoning Project +61 62 492930 %Australian National University Network mail: %PO Box 4 ACSNetwork: jdb@arp.anu.oz %Canberra ACT 2601 UUCP: {uunet, nttlab, ubc-vision, mcvax, ukc} %AUSTRALIA !munnari!arp.anu.oz!jdb %------------------------------------------------------------------------------ %Here is a TeX `program' I have written to generate a two-sided calendar. %Printed on both sides of a piece of A4 it makes a handy diary I can carry %in my wallet. % %The calendar is centred on the page, the calendar size and page size can %be changed easily. Printer limitations may require a smaller calendar. %For example, to print properly here I had to drop \calendarheight to 253mm. % %The year can also be changed simply, in which case the entire calendar is %appropriately reformatted. At present any number in 0-2400 will work. % %Due to my own taste, the week runs from sunday to saturday. With a small %amount of effort this could be changed. % %This was written on my Amiga, using Tom Rokicki's AmigaTeX (thanks Tom). % %Geoff Oakley Telephone: %School of EE and CS +61 2 697 4043 %University of NSW Network mail: %PO Box 1 ACSNetwork: geoffo@elecvax.oz %Kensington NSW 2033 UUCP: {{uunet, hplabs, ubc-vision, mcvax, enea, ukc, %AUSTRALIA prlb2}!munnari, decvax!mulga}!elecvax.oz!geoffo % % -=+##+=--=+##+=--=+##+=--=+##+=--=+##+=--=+##+=--=+##+=--=+##+=--=+##+=- % % TeX program to print 2-sided calendar % Year and calendar size can be changed \newcount\yearnum \yearnum=1753 \newdimen\calendarheight \calendarheight=275mm \newdimen\calendarwidth \calendarwidth=189mm % paper size (centred on full [A4] paper size) \hsize=210mm \hoffset=-1in \vsize=296mm \voffset=-1in % fonts used \font\datefont=cmr8 \font\titlefont=cmti10 scaled\magstep3 % dimension registers \newdimen\daywidth % width of 1 day \newdimen\dayheight % height of 1 row \newdimen\bannerheight % banner (days-of-week title) height \newdimen\bannersep % sep twixt banner and dates \newdimen\tmpdimen % number registers \newcount\monthnum % current month (1..12) \newcount\endofmonth % last date for current month (28..31) \newcount\datenum % current date (1..31) \newcount\daynum % current dayofweek (0..6) == (sun..sat) \newcount\pagenum % current page (0..1) \newcount\startpage % 1 before page starts, 0 otherwise \newcount\leapyear % 1 for leapyear, 0 otherwise \newcount\startday % first dayofweek for page 0 \newcount\nextstartday % first dayofweek for page 1 \newcount\endofpage % see use for description \newcount\tmp \newcount\tmpD \newcount\tmpC % initialisations \daywidth=\calendarwidth \divide\daywidth by7 % of the many definitions \def\titlestring{\titlefont\number\yearnum} % can be changed, % but be wary of long titles \def\setleap{\tmp=\yearnum \divide\tmp by4 \multiply\tmp by4 \advance\tmp by-\yearnum \ifnum\tmp=0 \global\leapyear=1 \tmp=\yearnum \divide\tmp by100 \multiply\tmp by100 \advance\tmp by-\yearnum \ifnum\tmp=0 %GREG \ifnum\yearnum>1582 %GB&USA \ifnum\yearnum>1752 \ifnum\yearnum>1752 \tmp=\yearnum \divide\tmp by400 \multiply\tmp by400 \advance\tmp by-\yearnum \ifnum\tmp=0 \global\leapyear= 1 \else \global\leapyear= 0 \fi \fi \fi \else \global\leapyear=0 \fi} %GREG\def\setstartday{\ifnum\yearnum>1582 %GB&USA\def\setstartday{\ifnum\yearnum>1752 \def\setstartday{\ifnum\yearnum>1752 \tmpC=\yearnum \advance\tmpC by-1 \divide\tmpC by100 \multiply\tmpC by100 \tmpD=\yearnum \advance\tmpD by-1 \advance\tmpD by-\tmpC \divide\tmpC by100 \tmp=\tmpD \advance\tmp by29 \divide\tmpD by4 \advance\tmp by\tmpD \advance\tmp by-\tmpC \advance\tmp by-\tmpC \divide\tmpC by4 \advance\tmp by\tmpC \tmpD=\tmp \divide\tmpD by7 \multiply\tmpD by7 \advance\tmp by-\tmpD \else \tmp=\yearnum \divide\tmp by28 \multiply\tmp by-28 \advance\tmp by\yearnum \tmpD=\tmp \advance\tmpD by-1 \divide\tmpD by4 \advance\tmp by\tmpD \advance\tmp by5 \tmpD=\tmp \divide\tmpD by7 \multiply\tmpD by-7 \advance\tmp by\tmpD \fi \global\startday=\tmp} \def\seteom{\global\endofmonth=\ifcase\monthnum \or31%jan \or\ifnum\leapyear=1 29%feb \else28 \fi \or31%mar \or30%apr \or31%may \or30%jun \or31%jul \or31%aug \or30%sep \or31%oct \or30%nov \or31%dec \or31%next jan \fi} \def\setrowheight{\tmp=27 %calculate weeks on page \ifcase\pagenum \ifnum\startday=1 \ifnum\leapyear=0 \tmp=26 \fi \fi \or %GREG \ifnum\yearnum=1582 %GB&USA \ifnum\yearnum=1752 \ifnum\yearnum=1752 \ifnum\nextstartday>2 \tmp=26 \else \tmp=25 \fi \else \ifnum\nextstartday=6 \tmp=28 \fi \fi \fi \advance\tmp by2 %allow for day names (banner) \dayheight=\calendarheight \divide\dayheight by\tmp \bannersep=\dayheight \divide\bannersep by10 \bannerheight=\dayheight \advance\bannerheight by-\bannersep \advance\bannerheight by-0.4pt} \def\incrday{\ifnum\daynum=6 \global\daynum=0 \else \global\advance\daynum by1 \fi} \def\incrdate{\ifnum\datenum=\endofmonth \global\advance\monthnum by1 \global\datenum=1 \seteom \ifnum\monthnum=7 \global\endofpage=1 \else \ifnum\monthnum=13 \global\endofpage=1 \fi \fi \else %GREG \ifnum\yearnum=1582 %GREG \ifnum\monthnum=10 %GREG \ifnum\datenum=4 %GB&USA \ifnum\yearnum=1752 %GB&USA \ifnum\monthnum=9 %GB&USA \ifnum\datenum=2 \ifnum\yearnum=1752 \ifnum\monthnum=9 \ifnum\datenum=2 %GREG \global\advance\datenum by11 %GB&USA \global\advance\datenum by12 \global\advance\datenum by12 \else \global\advance\datenum by1 \fi \else \global\advance\datenum by1 \fi \else \global\advance\datenum by1 \fi \fi} \def\datestring{\hbox{\ifnum\datenum>1 \datefont\number\datenum \else \bf\ifcase\monthnum day0 \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 \fi} \incrdate} \def\weekday#1{\vbox to\bannerheight{\vfil\hbox{#1}\vfil}} \def\dayofweek#1{\unskip\hbox to\daywidth{\hfil\weekday{#1}\hfil}} \def\vbar#1{\unskip\vrule height#1depth0mm\kern-0.4pt} \def\bannerbar{\vbar{\bannerheight}} \def\daybar{\vbar{\dayheight}} \def\rule#1{\hrule width#1\kern-0.4pt} \def\weekrule{\rule{\calendarwidth}} \def\banner{\weekrule \hbox{\bannerbar\dayofweek{Sunday} \bannerbar\dayofweek{Monday} \bannerbar\dayofweek{Tuesday} \bannerbar\dayofweek{Wednesday} \bannerbar\dayofweek{Thursday} \bannerbar\dayofweek{Friday} \bannerbar\dayofweek{Saturday} \bannerbar \unskip} \weekrule} \def\printtitle{\tmpdimen=\daywidth \multiply\tmpdimen by\daynum \daybar \hbox{\vbox to\dayheight {\vfil \hbox to\tmpdimen {\hfil \ifcase\pagenum \titlestring \or\fi \hfil} \vfil}}} \def\widetitle{\weekrule \hbox{\daybar \vbox to\dayheight {\vfil \hbox to\calendarwidth{\hfil\titlestring\hfil} \vfil} \daybar}} \def\daydate#1{\vbox to\dayheight{\vskip1mm\hbox{#1}\vfil}} \def\printday#1{\unskip\hbox to\daywidth{\hskip1mm\daydate{#1}\hfil}} \def\printalldays{\ifnum\startpage=1 \printtitle \global\startpage=0 \fi \loop \ifcase\endofpage %0=not eop \daybar \printday{\datestring} \or %1=eop first time \daybar \printday{} \global\endofpage=2 \global\nextstartday=\daynum %for next page \or %2=eop \printday{} \fi \incrday \ifnum\daynum>0 \repeat \daybar} % next day is Sunday-> finish \def\printallweeks{\loop \weekrule \hbox{\printalldays} \ifnum\endofpage=0 \repeat \weekrule} % let the fun begin \setleap \setstartday \monthnum=1 \datenum=1 \seteom \nopagenumbers \nointerlineskip \pagenum=0 \setrowheight \startpage=1 \endofpage=0 \daynum=\startday \hbox to \hsize {\hfil \vbox to \vsize {\vfil \banner \vskip\bannersep \ifnum\daynum=0 \widetitle \startpage=0 \fi \printallweeks \vskip\bannersep \banner \vfil} \hfil} \eject \pagenum=1 \setrowheight \startpage=1 \endofpage=0 \daynum=\nextstartday \hbox to \hsize {\hfil \vbox to \vsize {\vfil \banner \vskip\bannersep \ifnum\daynum=0 \startpage=0 \fi \printallweeks \vskip\bannersep \banner \vfil} \hfil} \eject \end