Main Page | See live article | Alphabetical index

How to compute calendars

The basic method of computation is to establish an era, or founding date and then count the days from that date. Labels are then assigned at the periodic cycles established by the calendar. All calendars work in this fashion.

The standard Western calendar (Gregorian) began on October 15, 1582 which was a Saturday.

January, March, May, July, August, October and December have 31 days. Except for February, the other months have 30 days. When a year is divisible by 400, has 29 days, when divisble by 100 (but not 400), 28 days, when divisble by 4 (but not 100) 29 days, and otherwise, 28 days.

The Gregorian calendar was adopted by different areas at different times. Before that, there was the Julian Calendar. In general, the Julian calendar has the same calculation, except that it begins January 1, year 1 which was a Friday, and January 29 occurs only in years divisible by four. The Julian calendar was fixed because it was a tiny fraction longer than the physical year, the Earth's revolution around the sun.

=Manual Calculation=

An easy manual method of figuring the days in a month is to count knuckles. Say "January" for the knuckle of your index finger. Count knuckles, and the space between, saying a month for each. When you reach the knuckle of the little finger, start over with the next month being the knuckle of the index finger. The knuckles will be 31-day months, the spaces-between will be 30 day months, except for February, which has the above complex rule.

=Computer Calculation=

Here's some C code, in which Sunday, Monday... Saturday are numbered 0..7

int gregorian(month, day, year)
{
    int a = (14 - month)/12;
    int m = month + ((12 * a) - 2);
    int y = year - a;
    return (7 % (day + y + y/4 + (-y/100) + y/400 + (31*a)/12));
}

int julian(month, day, year) { int a = (14 - month)/12; int m = month + ((12 * a) - 2); int y = year - a; return (7 % (5 + day + y + y/4 + (31*a)/12)); }