Ancient Mayan calendar - how to calculate the date?
Hello reader!
If you remember, more recently, the calendar of ancient Mayans was on everyone's hearing. Few people have paid attention to the burning issue of the end of the reckoning of the once great civilization. Now I propose to delve into the mathematical essence of the question - how to calculate the Mayan calendar date.
In my story I will show how to get the Mayan calendar date from the date of the usual Gregorian calendar, giving examples of algorithms in Python.
First, briefly repeat the theory of the calendar itself.
The Mayan calendar consists of three main parts. This is a long account, tzolkin and haab.
The fourth optional part of the calendar is the listing of the lords of the night. There are only nine of them and they follow each other. Something like a nine-day week. The names of the lords did not survive, so it is customary to denote them simply: G1, G2, G3, G4, G5, G6, G7, G8, G9.
What else should you know? It is not known for certain from what day the Gregorian calendar should be counted. There are many authoritative opinions on this subject, but now two versions are popular - the so-called correlations 584283 and 584285. The first is called GMT-correlation, the second - Thompson-Lounsbury correlation or astronomical correlation. I note that December 21, 2012 is the end of the calendar of GMT-correlation, but recently the opinion that the second correlation is more true is being increasingly supported. According to her, the "end of all things" comes two days later - December 23, 2012.Hooray, comrades! Of course, this makes it much easier for us.
So ... All calendar values can be calculated, knowing the number of days since the beginning of the Mayan era. We will arbitrarily call them “Mayan days”, by analogy with the Julian days.
Mayan days for the dates of our era are calculated as the remainder of dividing the expression (D + 1721425 - C) by 1872000, where D is the number of days from the beginning of our era to the given date, C is the correlation value, 1872000 is the number of days in the Mayan era. Thus, in Python, the formula is:
getting a D value in Python is very easy, just import the datetime module and then if the current date is current_date = datetime.date.today (), then D = current_date.toordinal (). Or simply - D = datetime.date.today (). Toordinal ()
Now, knowing the value of the Mayan days, we can calculate the rest. Let's start with a long account.
The long score is the score of the kin (1 kin = 1 day), 20 kin are 1 vinil, 18 vinals are 1 tun or 20 × 18 = 360 kin, 20 tuns are 1 katun or 20 × 18 × 20 = 7200 kin, 20 katuns - 1 baktun or 20 × 18 × 20 × 20 = 144,000 kin. The era consists of 13 baktuns, therefore the era lasts 20 × 18 × 20 × 20 × 13 = 1872000 kin. For example, the last date of the Mayan era in the long run will be 12.19.19.17.17.
So, in order to get the current value of Baktun, Katun, Tuna, Vinal and Kina, we need to divide the Mayan days first by 144000 (we will get the Baktun), then divide the remainder by 7200 (we will get the Katun), then divide the next remainder by 360 (we will get the tun ), then the next remainder is again divided by 18 (blamed), and the last remainder will give us a kin.
In Python, everything is much simpler than in words:
where M is the previously calculated Mayan days.
As a result, we get a list containing all the long count values we need.
One more remark. Since it is not possible to find a living representative of the ancient Mayan people, who would still use the calendar of their ancestors, it remains a mystery, as the baktun expresses during the era change. If the era begins with a zero baktun, then it is very obvious that the beginning of the new era will be the number 0.0.0.0.0. But the Mayans allegedly avoided a completely zero date, so they supposedly expressed the beginning of a new era as 13.0.0.0.0. Further, it is not clear what the next day of the new era looks like - 13.0.0.0.1 or 0.0.0.0.1. A different idea does not affect the calculation of the date, so let's move on.
Let's take tzolkin. Tzolkin consists of two parts - the day number for the 13-day cycle and the name of the day for the 20-day cycle. Let's call them T2 and T1 (in places I change them purely for convenience, do not pay attention).
Consequently,
where 3 and 19 are constants, meaning that the beginning of the Tsolkin cycles did not coincide with the beginning of the Mayan era.
Therefore, let the tuple of names of the days of tzolkin be
then the name of the day
Now it is the turn and the haaba.
With him, too, everything is quite simple. Let the day of the haaba month be H2, and the month H1 itself (interchanging for ease of calculation).
From here
where the constant 348, as in the case of tzolkin, means that the beginning of the haab did not coincide with the beginning of the era.
And, according to a familiar pattern, let us have a tuple of names for the months of the haab
then the name of the month
For completeness, it remains to calculate the lord of the night. Easy peasy:
Actually, all this is done by my program, the source code of which is available at https://bitbucket.org/mystic-mirage/mayanc (you can pick it up by git at git@bitbucket.org: mystic-mirage / mayanc.git )
Here the command line parameters that the program accepts:
-d <date of the Gregorian calendar>, by default - the current date;
-g <input date format>, by default '% Y-% m-% d' - the parameter accepts all qualifiers available in the strptime () function of Python, but only year, month and day are important;
-f <output date format>, default '% C,% Z% H',
possible qualifiers:
% b - baktun,
% k - katun,
% t - tun,
% w - blame,
% i - kin,
% z1 is the numerical value of the name of the Tolkien day (20-day cycle),
% z2 is the number of the day of tzolkin (the 13-day cycle),
% z3 is the name of the day of Tzolkin (20-day cycle),
% h1 is the numerical value of the month of the haaba,
% h2 - day of the haaba month,
% h3 - month of the haaba,
% l - number of the lord of the night,
% L - lord of the night,
% C - long account (equivalent to% b.% k.% t.% w.% i),
% Z - tzolkin (equivalent to% z2% z3),
% H - haab (equivalent to% h2% h3);
-c <correlation> - indicates the applied correlation, can take any value, and the constants can also be specified: gmt and tl, by default - gmt, i.e. 584283;
-s <scenario> - a variant of the interpretation of the baktun during the period of changing the era, by default 1,
possible values:
1 - 13.0.0.0.0, but 0.0.0.0.1,
2 - 13.0.0.0.0 and 13.0.0.0.1,
3 - 0.0.0.0.0.0 and 0.0.0.0.1;
--gmt - equivalent to -c gmt;
--tl is equivalent to -c tl;
--baktun - equivalent to -f '% b';
--katun - equivalent to -f '% k';
--tun - equivalent to -f '% t';
--winal - equivalent to -f '% w';
--kin is equivalent to -f '% i';
--tzol1 - equivalent to -f '% t1';
--tzol2 - equivalent to -f '% t2';
--tzol3 - equivalent to -f '% t3';
--haab1 - equivalent to -f '% h1';
--haab2 - equivalent to -f '% h2';
--haab3 - equivalent to -f '% h3';
--lord1 - equivalent to -f '% l';
--lord2 - equivalent to -f '
--long - equivalent to -f '% C' or -f '% b.% k.% t.% w.% i';
--tzol - equivalent to -f '% Z' or -f '% z2% z3';
--haab - equivalent to -f '% H' or -f '% h2% h3';
--bc - indicates that the original Gregorian date is in the time interval BC, that is, the combination of the parameters -d 3114-08-11 --bc means that the original date is August 11, 3114 BC;
--no-l10n - do not use localized names.
Note. Adding the --bc key made the code very complicated, in particular, I had to rewrite the date recognition in a given format a bit (due to the fact that 1 year BC was suddenly a leap year) and supplemented with the calculation of Mayan days. But now any date in the range from January 1, 9999 BC can be the input parameter. e. - until December 31, 9999 e.
The program can be used not only from the command line, but also as a module for import:
The following functions are available:
todaydatetuple () - returns a tuple containing the current date according to the Gregorian calendar (year, month, day), is used for other functions and is of no use to a simple user;
getmayandays (g_tuple = todaydatetuple (), cor = 584283, bc = False) —takes a date tuple (year, month, day), correlation value, era flag (AD - False, BC — True) and returns Mayan days;
getlongcount (m_days, scenario = 1) - takes Mayan days and the type of scenario, and returns a tuple with the values of the long score (baktun, katun, tun, vinil, kin);
gettzolkin (m_days) - takes Mayan days and returns a tuple consisting of values of 20- and 13-day tsolkin cycles;
gethaab (m_days) - accepts Mayan days and returns a tuple with the values of the month and the day of the haab;
getlord (m_days) - takes Mayan days and returns the serial number of the sovereign of the night.
There are also such tuples:
tzolkinlist - contains the names of days according to the 20-day cycle of tzolkin;
haablist - contains the names of the months of the haab;
lordlist - contains the names of the lords of the night, but since they are not known, the tuple contains the notation (G1 — G9);
There are also such constants:
gmt = 584283
tl = 584285
default_cor = gmt
default_fmt = '% C,% Z% H', which in essence is equivalent to such a set of qualifiers - '% b.% K.% T.% W.% I ,% z2% z3% h2% h3 '
default_sce = 1
The script can be integrated with conky. Actually for this he was written.

If you remember, more recently, the calendar of ancient Mayans was on everyone's hearing. Few people have paid attention to the burning issue of the end of the reckoning of the once great civilization. Now I propose to delve into the mathematical essence of the question - how to calculate the Mayan calendar date.
In my story I will show how to get the Mayan calendar date from the date of the usual Gregorian calendar, giving examples of algorithms in Python.
First, briefly repeat the theory of the calendar itself.
The Mayan calendar consists of three main parts. This is a long account, tzolkin and haab.
The fourth optional part of the calendar is the listing of the lords of the night. There are only nine of them and they follow each other. Something like a nine-day week. The names of the lords did not survive, so it is customary to denote them simply: G1, G2, G3, G4, G5, G6, G7, G8, G9.
What else should you know? It is not known for certain from what day the Gregorian calendar should be counted. There are many authoritative opinions on this subject, but now two versions are popular - the so-called correlations 584283 and 584285. The first is called GMT-correlation, the second - Thompson-Lounsbury correlation or astronomical correlation. I note that December 21, 2012 is the end of the calendar of GMT-correlation, but recently the opinion that the second correlation is more true is being increasingly supported. According to her, the "end of all things" comes two days later - December 23, 2012.
So ... All calendar values can be calculated, knowing the number of days since the beginning of the Mayan era. We will arbitrarily call them “Mayan days”, by analogy with the Julian days.
Mayan days for the dates of our era are calculated as the remainder of dividing the expression (D + 1721425 - C) by 1872000, where D is the number of days from the beginning of our era to the given date, C is the correlation value, 1872000 is the number of days in the Mayan era. Thus, in Python, the formula is:
M = (D + 1721425 – C) % 1872000
getting a D value in Python is very easy, just import the datetime module and then if the current date is current_date = datetime.date.today (), then D = current_date.toordinal (). Or simply - D = datetime.date.today (). Toordinal ()
Now, knowing the value of the Mayan days, we can calculate the rest. Let's start with a long account.
The long score is the score of the kin (1 kin = 1 day), 20 kin are 1 vinil, 18 vinals are 1 tun or 20 × 18 = 360 kin, 20 tuns are 1 katun or 20 × 18 × 20 = 7200 kin, 20 katuns - 1 baktun or 20 × 18 × 20 × 20 = 144,000 kin. The era consists of 13 baktuns, therefore the era lasts 20 × 18 × 20 × 20 × 13 = 1872000 kin. For example, the last date of the Mayan era in the long run will be 12.19.19.17.17.
So, in order to get the current value of Baktun, Katun, Tuna, Vinal and Kina, we need to divide the Mayan days first by 144000 (we will get the Baktun), then divide the remainder by 7200 (we will get the Katun), then divide the next remainder by 360 (we will get the tun ), then the next remainder is again divided by 18 (blamed), and the last remainder will give us a kin.
In Python, everything is much simpler than in words:
d = М
result = []
for i in (144000, 7200, 360, 20, 1):
t, d = divmod(d, i)
result.append(t)
where M is the previously calculated Mayan days.
As a result, we get a list containing all the long count values we need.
One more remark. Since it is not possible to find a living representative of the ancient Mayan people, who would still use the calendar of their ancestors, it remains a mystery, as the baktun expresses during the era change. If the era begins with a zero baktun, then it is very obvious that the beginning of the new era will be the number 0.0.0.0.0. But the Mayans allegedly avoided a completely zero date, so they supposedly expressed the beginning of a new era as 13.0.0.0.0. Further, it is not clear what the next day of the new era looks like - 13.0.0.0.1 or 0.0.0.0.1. A different idea does not affect the calculation of the date, so let's move on.
Let's take tzolkin. Tzolkin consists of two parts - the day number for the 13-day cycle and the name of the day for the 20-day cycle. Let's call them T2 and T1 (in places I change them purely for convenience, do not pay attention).
Consequently,
T1 = (M + 19) % 20
T2 = (M + 3) % 13 + 1
where 3 and 19 are constants, meaning that the beginning of the Tsolkin cycles did not coincide with the beginning of the Mayan era.
Therefore, let the tuple of names of the days of tzolkin be
t1 = ("Imix'", "Ik'", "Ak'b'al", "K'an", "Chikchan", "Kimi", "Manik'", "Lamat", "Muluk", "Ok", "Chuwen", "Eb'", "B'en", "Ix", "Men", "K'ib'", "Kab'an", "Etz'nab'", "Kawak", "Ajaw")
then the name of the day
T1s = t1[T1]
Now it is the turn and the haaba.
With him, too, everything is quite simple. Let the day of the haaba month be H2, and the month H1 itself (interchanging for ease of calculation).
From here
H1, H2 = divmod((M + 348) % 365, 20)
where the constant 348, as in the case of tzolkin, means that the beginning of the haab did not coincide with the beginning of the era.
And, according to a familiar pattern, let us have a tuple of names for the months of the haab
h1 = ("Pop", "Wo", "Sip", "Sotz'", "Tzek", "Xul", "Yaxk'", "Mol", "Ch'en", "Yax", "Sac", "Keh", "Mak", "K'ank'in", "Muwan", "Pax", "K'ayab'", "Kumk'u", "Wayeb'")
then the name of the month
H1s = h1[H1]
For completeness, it remains to calculate the lord of the night. Easy peasy:
G = (M + 8) % 9 + 1
Actually, all this is done by my program, the source code of which is available at https://bitbucket.org/mystic-mirage/mayanc (you can pick it up by git at git@bitbucket.org: mystic-mirage / mayanc.git )
Here the command line parameters that the program accepts:
-d <date of the Gregorian calendar>, by default - the current date;
-g <input date format>, by default '% Y-% m-% d' - the parameter accepts all qualifiers available in the strptime () function of Python, but only year, month and day are important;
-f <output date format>, default '% C,% Z% H',
possible qualifiers:
% b - baktun,
% k - katun,
% t - tun,
% w - blame,
% i - kin,
% z1 is the numerical value of the name of the Tolkien day (20-day cycle),
% z2 is the number of the day of tzolkin (the 13-day cycle),
% z3 is the name of the day of Tzolkin (20-day cycle),
% h1 is the numerical value of the month of the haaba,
% h2 - day of the haaba month,
% h3 - month of the haaba,
% l - number of the lord of the night,
% L - lord of the night,
% C - long account (equivalent to% b.% k.% t.% w.% i),
% Z - tzolkin (equivalent to% z2% z3),
% H - haab (equivalent to% h2% h3);
-c <correlation> - indicates the applied correlation, can take any value, and the constants can also be specified: gmt and tl, by default - gmt, i.e. 584283;
-s <scenario> - a variant of the interpretation of the baktun during the period of changing the era, by default 1,
possible values:
1 - 13.0.0.0.0, but 0.0.0.0.1,
2 - 13.0.0.0.0 and 13.0.0.0.1,
3 - 0.0.0.0.0.0 and 0.0.0.0.1;
--gmt - equivalent to -c gmt;
--tl is equivalent to -c tl;
--baktun - equivalent to -f '% b';
--katun - equivalent to -f '% k';
--tun - equivalent to -f '% t';
--winal - equivalent to -f '% w';
--kin is equivalent to -f '% i';
--tzol1 - equivalent to -f '% t1';
--tzol2 - equivalent to -f '% t2';
--tzol3 - equivalent to -f '% t3';
--haab1 - equivalent to -f '% h1';
--haab2 - equivalent to -f '% h2';
--haab3 - equivalent to -f '% h3';
--lord1 - equivalent to -f '% l';
--lord2 - equivalent to -f '
--long - equivalent to -f '% C' or -f '% b.% k.% t.% w.% i';
--tzol - equivalent to -f '% Z' or -f '% z2% z3';
--haab - equivalent to -f '% H' or -f '% h2% h3';
--bc - indicates that the original Gregorian date is in the time interval BC, that is, the combination of the parameters -d 3114-08-11 --bc means that the original date is August 11, 3114 BC;
--no-l10n - do not use localized names.
Note. Adding the --bc key made the code very complicated, in particular, I had to rewrite the date recognition in a given format a bit (due to the fact that 1 year BC was suddenly a leap year) and supplemented with the calculation of Mayan days. But now any date in the range from January 1, 9999 BC can be the input parameter. e. - until December 31, 9999 e.
The program can be used not only from the command line, but also as a module for import:
from mayanc import *
The following functions are available:
todaydatetuple () - returns a tuple containing the current date according to the Gregorian calendar (year, month, day), is used for other functions and is of no use to a simple user;
getmayandays (g_tuple = todaydatetuple (), cor = 584283, bc = False) —takes a date tuple (year, month, day), correlation value, era flag (AD - False, BC — True) and returns Mayan days;
getlongcount (m_days, scenario = 1) - takes Mayan days and the type of scenario, and returns a tuple with the values of the long score (baktun, katun, tun, vinil, kin);
gettzolkin (m_days) - takes Mayan days and returns a tuple consisting of values of 20- and 13-day tsolkin cycles;
gethaab (m_days) - accepts Mayan days and returns a tuple with the values of the month and the day of the haab;
getlord (m_days) - takes Mayan days and returns the serial number of the sovereign of the night.
There are also such tuples:
tzolkinlist - contains the names of days according to the 20-day cycle of tzolkin;
haablist - contains the names of the months of the haab;
lordlist - contains the names of the lords of the night, but since they are not known, the tuple contains the notation (G1 — G9);
There are also such constants:
gmt = 584283
tl = 584285
default_cor = gmt
default_fmt = '% C,% Z% H', which in essence is equivalent to such a set of qualifiers - '% b.% K.% T.% W.% I ,% z2% z3% h2% h3 '
default_sce = 1
The script can be integrated with conky. Actually for this he was written.
