\documentclass{article}
\nofiles
\renewcommand{\div}{\rm\,div\,}\newcommand{\mod}{\rm\,mod\,}
\newcommand{\dfrac}{\displaystyle\frac}
\begin{document}
\section*{\texttt{ReadMe} file --- Instructions}
This file explains the use of \verb|CalXXXX.tex| and \verb|Cal2000.tex| files, possible
modifications and gives the mathematical background for the calculation of the calendar. Both files
are for \LaTeXe, and use the \verb|array.sty| package. At the end, there are some interesting
numerical values and historical facts.
\subsection*{The use}
To print a calendar for a given year, use \verb|CalXXXX.tex| file. \LaTeXe it, type in the year
(for example 2002), and the calendar for that year is produced. For the year B. C., enter the
negative number (for example $-6$), and for the current year, \number\year th, you can press the
ENTER key only.
To print calendar for the years 1990--2020, use \verb|Cal2000.tex| file. \LaTeXe it and you will
have the calendar for all that years.
\subsection*{Possible modifications}
In both files there is a peace of code clearly denoted for safe modifications.
In \verb|CalXXXX.tex|, the most important changes are for a language: \verb|\Jan|, \dots
\verb|\Dec| define names of the months. You can also set type of the calendar: Gregorian
(\verb|\Julianfalse|) or Julian (\verb|\Juliantrue|). For details, see explanations later. Some
misunderstanding could be for 0th year; normally it doesn't exist (before 1st is a $-1$st year),
but if, for some reason, you need a 0th year, set \verb|\ZeroExisttrue| and the 0th year will exist
(before 1st is 0th, and before it $-1$st). \verb|\BC| and \verb|\AD| are text after the year (in
English, $-6$th year is 6~BC and 6th year is 6~AD).
In the \verb|Cal2000.tex|, the most important changes are also for a language. Change definition
for \verb|\YearMonths| and \verb|\Day| according to your language.
Both files have a command \verb|\CmRulefalse|. If you change it to a \verb|\CmRuletrue|, you will
see a centimeter scale at the right edge.
Beside of these, other modifications are possible, but not recommended.
\subsection*{Mathematical background}
In both files, the day $x$ (0 for Sunday, 1 for Monday, etc.) for a date $d.m.y$ is calculated as
\[ x=\left\{\begin{array}{ll}
x_0 \mod 7 & \mbox{if $m<3$} \\ (x_0-(4m+23) \div 10) \mod 7 & \mbox{if $m\ge3$}
\end{array}\right. \]
where
\[x_0=365y+31m+d+3+k \div 4-(k \div 100+1)\cdot3 \div 4\]
and
\[ k=\left\{\begin{array}{ll} y-1 & \mbox{if $m<3$}\\ y & \mbox{if $m\ge3$} \end{array}\right.\]
This formulae are used in both files. In \verb|CalXXXX.tex|, you can see how \TeX calculates. In
\verb|Cal2000.tex|, since the years 1990--2020 are fixed, there is no need to calculate anything,
but the first day for all months for the years 1990--2020, are produced with the following Pascal
code:
\begin{verbatim}
program cal(output);
var x,y,m,k: longint;
begin writeln('Year J F M A M J J A S O N D');
for y:=1990 to 2020 do
begin write(y,' ');
for m:=1 to 12 do
begin x:=365*y+31*m+4; { 4=d+3 }
if m<3 then k:=y-1 else k:=y;
x:=x+k div 4-(k div 100+1)*3 div 4;
if m>=3 then x:=x-(4*m+23) div 10;
x:=x mod 7;
write(' ',x)
end; writeln;
end;
end.
\end{verbatim}
\subsection*{Numerical values}
The lengths of solar (tropical) year and lunar month in days are
\[ Y=365.24219872,\quad M=29.530588. \]
(These are values for a period December 31st, 1900, at 12h --- since it slowly decreases.) The
solar calendar should have about 365.24 days in a year (on average), while the lunar calendar
should have months of 29.5 days (usually, 30 and 29 alternately). The lunisolar calendar should
have both, but the ratio of these two lengths $Y/M=12.36826706\ldots$ is not an integer and most
years should have 12 and leap years 13 months. In 432 BC, Athens astronomer Meton, discover that in
19 years there are almost exactly 235 lunar months ($19\times 12.36826706=234.997$). This became a
base for all calendar with lunar months and solar year.
The Julian year has 365.25 days (on average), and the difference is $0.0078013 \linebreak[1]
\mbox{days}=11'14''$ or 1 day in 128 years, while the Gregorian year has 365.2425 days, with the
difference of $0.0003013 \mbox{ days} =26''$ or 1 day in 3319 years. More precise calendar will
follow from the expansion of the length of the tropical year in an infinite fraction
\[ {365.24219872}
=365+\dfrac{1}{4+\dfrac{1}{7+\dfrac{1}{1+\dfrac{1}{3+\dfrac{1}{5+\dfrac{1}{5+\cdots}}}}}}
\]
With the first fraction only, we have $365+\frac14=365.25$ days, what is Julian year. With the
first two fraction, $365+\frac{1}{4+\frac{1}{7}}=365+\frac{7}{29}=365.2414$ and with the three
$365+\frac{8}{33}=365.2424$ what is better then Gregorian year. With the four
$365+\frac{31}{128}=365.2421875$ with the difference $0.0000112 \mbox{ days}=1''$ or 1 day in
almost 10\,000 years. So, if in a cycle of 128 years we put 31 leap years, the calendar will be
almost perfect.
\subsection*{Brief History}
In Babylon a calendar had 12 lunar months of 30 days each, with added extra month when necessary to
keep the months in line with the seasons of the year. Later, a year of 354 days was introduced with
12 months with intercalations in the years 3, 6, 8, 11, 14, 17, and 19 of the 19-year cycle. In
Iran, Zoroastrian calendar has year of 12 months of 30 days, plus five days, giving totally 365.
The ancient Egyptians measured the solar year as 365 days, divided into 12 months of 30 days each,
with 5 extra days at the end. About 238~BC King Ptolemy~III added an extra day to every fourth
year. In ancient Greece a lunar calendar was in use, with a year of 354 days. In Rome, the year had
10 months with 304 days and began with March. Two more months, January and February were added
later in the 7th century BC. Furthermore, an extra month had to be intercalated approximately every
second year.
In 45~BC Julius Caesar, upon the advice of the Alexandrian astronomer Sosigenes, decided to use a
solar calendar similar to Egyptian. This calendar, known today the Julian calendar, had the normal
year at 365 days, and the leap year, every fourth year, at 366 days. In this calendar January,
March, May, July, September, and November had 31 days, other months 30 days, while February had 29
or 30 days. This calendar also established the order of the months and the days of the week as they
exist in present-day calendars. Julius Caesar also changed the name of the month Quintilis to
Julius (July). In 8~AD the emperor Caesar Augustus renamed the month Sextilis to Augustus (August),
increased it to 31 days, reduced September and November to 30 days, and increased October and
December to 31 days. Such complicated calendar was adopted by Christian church and spread to western
world.
Since the year in Julian calendar was some longer then solar year, this discrepancy accumulated
until by 1582 the error was 10 days. To fix it, Pope Gregory~XIII issued a decree dropping 10 days
from the calendar and order that century years divisible by 400 should be leap years only. Catholic
states adopted this new calendar immediately, but other counties did that later. Britain adopted it
in 1752, Denmark and the Dutch and German Protestant states in 1699-1700, Soviet Union in 1918, and
Greece in 1923. The monarch republic Holy Mountain, in Greece, is only territory with the official
use of the Julian calendar, but some Orthodox churches also keep the Julian calendar for religious
use.
The Islamic calendar is a purely lunar. It has 12 lunar months alternately 30 and 29 days long. In
each thirty years the 2nd, 5th, 7th, 10th, 13th, 16th, 18th, 21st, 24th, 26th, and 29th years have
the last month as leap month with 30 instead of 29 days. So the year has 354 or 355 days. There are
no intercalations of months and the months regress through all the seasons every $32\frac12$ years.
The Jewish calendar is lunisolar, based on 12 lunar months of 29 days or 30 days. Such year has 354
days, but an extra month of 30 days is intercalated in the 3rd, 6th, 8th, 11th, 14th, 17th, and
19th years in a 19-year cycle. This gives an average length of 365.05 days.
The Chinese calendar is also lunisolar, its year consisting of 12 months of alternately 29 and 30
days, equal to 354 days. Intercalary months are inserting to keep the calendar year in step with
the solar year of 365 days.
\subsection*{Notices}
These files may be freely used on any number of machines for any time period. It can be freely
copied and distributed, on the condition that the distribution will be complete and with no
modification.
The author disclaims all warranties as to this software, whether express or implied, including
without limitation any implied warranties of merchantability or fitness for a particular purpose.
\subsection*{}
\copyright Slobodan Jankovi\'c, \texttt{slobodan@archimed.filfak.ni.ac.yu}
\end{document}
\[ \frac{365.24219872}{29.530588} = 12.36826706\ldots
=12+\cfrac{1}{2+\cfrac{1}{1+\cfrac{1}{2+\cfrac{1}{1+\cfrac{1}{1+\cfrac{1}{16+\cfrac{1}{1+\dotsb}}}}}}}
\]