Wolfram Language

Units & Dates

Convert to the Mayan Calendar

Identify the epoch (or start date) for the Mayan Long Count calendar as a Julian date.

In[1]:=
Click for copyable input
epoch = JulianDate["Modified", DateObject[{-3114, 8, 11}, TimeZone -> 0]];

Create a function to convert from Mayan Long Count calendar units to a Julian date.

In[2]:=
Click for copyable input
JulianFromMayanLongCount[{baktun_, katun_, tun_, uinal_, kin_}] := epoch + 144000*baktun + 7200*katun + 360*tun + 20*uinal + kin

FromJulianDate can be used to test an example input.

In[3]:=
Click for copyable input
example = JulianFromMayanLongCount[{7, 17, 18, 19, 2}]
Out[3]=
In[4]:=
Click for copyable input
FromJulianDate["Modified", example, TimeZone -> 0]
Out[4]=

Create a function to convert directly from Mayan Long Count to Gregorian date objects.

In[5]:=
Click for copyable input
GregorianFromMayanLongCount[date_] := DateValue[ FromJulianDate["Modified", JulianFromMayanLongCount[date], TimeZone -> 0], "Day", DateObject]
In[6]:=
Click for copyable input
GregorianFromMayanLongCount[{7, 17, 18, 19, 2}]
Out[6]=

Create a function to convert from a Julian date to Mayan Long Count calendar units.

In[7]:=
Click for copyable input
JulianToMayanLongCount[date_] := NumberDecompose[ Floor[date - epoch], {144000, 7200, 360, 20, 1} ]

JulianDate can be used to interpret any date input into a Julian date, which is then fed into JulianToMayanLongCount.

In[8]:=
Click for copyable input
DateToMayanLongCount[date_] := Block[{$TimeZone = 0}, JulianToMayanLongCount[JulianDate["Modified", date]] ]

This function will now accept any input date and will return the corresponding Mayan Long Count calendar date list.

In[9]:=
Click for copyable input
DateToMayanLongCount["May 4th, 2015"]
Out[9]=
In[10]:=
Click for copyable input
DateToMayanLongCount[AbsoluteTime[]]
Out[10]=
In[11]:=
Click for copyable input
DateToMayanLongCount[Today]
Out[11]=

These two functions can be used to convert to and from the Long Count Mayan calendar.

In[12]:=
Click for copyable input
DateToMayanLongCount[{1900, 1, 1}]
Out[12]=
In[13]:=
Click for copyable input
DateToMayanLongCount[{1900, 1, 1}]; GregorianFromMayanLongCount[%]
Out[13]=

Related Examples

de es fr ja ko pt-br ru zh