1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
%%% Save file as: YEARCAL.TEX Source: FILESERV@SHSU.BITNET
%%% @LaTeX-file{
%%% author = "Michael Barr",
%%% version = "1.0",
%%% date = "1992-06-24",
%%% time = "16:35 EDT",
%%% filename = "yearcal.tex",
%%% address = "Department of Mathematics & Statistics"
%%% McGill University
%%% 805 Sherbrooke St. W
%%% Montreal, QC
%%% Canada H3A 2K6",
%%% telephone = "(514) 398-3806",
%%% FAX = "(514) 398-3899",
%%% email = "barr@math.mcgill.ca (Internet)",
%%% codetable = "ISO/ASCII",
%%% keywords = "LaTeX, year calendar"
%%% checksum = "53683 132 503 5111",
%%% supported = "yes",
%%% docstring = "
%%% This LaTeX file prints the correct Gregorian calendar for any
%%% year between the adoption of the Gregorian calendar (which
%%% happened during the 18th, 19th and even 20th century,
%%% depending on country) and the year 4000. That year is
%%% supposed, according to current plans, not to be a leap year,
%%% although, strictly speaking, that ought to happen in the year
%%% 3200.
%%%
%%% The current definition of the Gregorian calendar is:
%%% Years divisible by 4 are leap years; except
%%% years divisible by 100 are not leap years; except
%%% years divisible by 400 are leap years; except
%%% years divisible by 4000 are not leap years.
%%% So the years 1800 and 1900 were not leap years, but 2000 will be.
%%% }
%%% ====================================================================
% The current definition of the Gregorian calendar is:
% Years divisible by 4 are leap years; except
% years divisible by 100 are not leap years; except
% years divisible by 400 are leap years; except
% years divisible by 4000 are not leap years.
% So the years 1800 and 1900 were not leap years, but 2000 will be.
\typeout{}
\typein[\theyear]{Please enter the year:}
\newcount\yearnum \yearnum=\theyear
\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&Mo&Tu&We&Th&Fr&Sa\\ \hline
\day{ 1}&\day{ 2}&\day{ 3}&\day{ 4}&\day{ 5}&\day{ 6}&\day{ 7}\\
\day{ 8}&\day{ 9}&\day{10}&\day{11}&\day{12}&\day{13}&\day{14}\\
\day{15}&\day{16}&\day{17}&\day{18}&\day{19}&\day{20}&\day{21}\\
\day{22}&\day{23}&\day{24}&\day{25}&\day{26}&\day{27}&\day{28}\\
\day{29}&\day{30}&\day{31}&\day{32}&\day{33}&\day{34}&\day{35}\\
\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 \datenum by#1
\ifnum\datenum>0 \ifnum\datenum>\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}}
|