## Introduction

The program is a calculator to convert dates of Maya “long counter” calendar to Gregorian calendar.

Maya long counter calendar was used by ancient Maya culture development in Mesoamerica before the arrival of Columbus 1492. Maya's culture has taken unusual interest because of supposed prophesies about the end of world in 2012 related to the end of the round of Maya long counter calendar. This calculator maybe helps to better understand these matters. You can find a lot of information about Maya on the internet.

Gregorian calendar is our actual calendar in use expressed in year, month and days.

## Background

The Mesoamerican Long Count calendar is a non-repeating, vigesimal (base-20) and base-18 calendar used by several Pre-Columbian Mesoamerican cultures, most notably the Maya. For this reason, it is sometimes known as the Maya (or Mayan) Long Count calendar.

Using a modified vigesimal tally, the Long Count calendar identifies a day by counting the number of days passed since a mythical creation date that corresponds to August 11, 3114 BCE in the Gregorian calendar.

Maya long counter is expressed in Baktun, Katun, Tun, Uinal & Kin number which program can convert to a decimal number equivalent to number of days elapsed since initial value.

In order to convert at Gregorian calendar is a little more complicated because Gregorian uses 3 values, year, month & day, and needs to take care of leap years.

The way to help in this conversion is by using Julian Day (JD. This is a calendar not commonly used by normal people, but well known by astronomers and geologists. JD is also (like Maya long counter) a continuous counter of days since January 1^{st} 4113 BC.

Long counter and JD are values of number of days, so to convert between them, we need to know what is the value in JD when the long counter starts. This value is known as “Maya Correlation” and has been a discussion theme for Maya researchers. The value more accepted is called “Goodman Martinez Thompson” of GMT correlation and its value is JD 584.283 equivalent to August 11, 3114 BC in Gregorian calendar (proleptic).

Known correlation then the date in JD will be the long counter value plus the correlation. With date in JD then we convert JD to Gregorian data using some algorithms already known.

To convert JD to Gregorian and vice versa, the program uses the algorithm token from Wikipedia and is implemented in C# code.

## Using the Code

The core of the program is a number of routines to implement algorithms to convert between different calendars:

`Maya2Gregorian`

`Julian2Gregorian`

`JulianDay2JuliaDate`

`Gregorian2JulianDay `

`Gregorian2Maya`

Other routines implement inputs and show results.

One example is routine `Julian2Gregorian `

to convert a number of days according to Julian days (JD) to a date according to Gregorian form (years, month, day and day of the week).

The algorithm requires use of mathematic operation **mod**

(module) that can be implemented by C# method **Math.DivRem**

. The method executes quotient between two integers and also calculates the remainder so remainder is the same thing as the module.

Almost all operations use integers of 32 bits. Despite comments about advanced mathematics used by Maya, only operation with integers is enough.

public void Julian2Gregorian(int JD, out int Y, out int M, out int D, out int WD)
{
int j, g, c, b, a, y, m, d;
int dg, dc, db, da;
j = (int)JD + 32044;
g = Math.DivRem(j, 146097, out dg);
c = (dg / 36524 + 1) * 3 / 4;
dc = dg - (c * 36524);
b = Math.DivRem(dc, 1461, out db);
a = (db / 365 + 1) * 3 / 4;
da = db - (a * 365);
y = g * 400 + c * 100 + b * 4 + a;
m = (da * 5 + 308) / 153 - 2;
d = da - (m + 4) * 153 / 5 + 122;
Y = y - 4800 + Math.DivRem((m + 2), 12, out M);
M += 1;
D = d + 1;
Math.DivRem((int)JD, 7, out WD);
}

## History

- June 22, 2011 - First issue