PHILADELPHIA REFLECTIONS
Musings of a Philadelphia Physician who has served the community for six decades

Return to Home

Converting Mayan Dates

The Mayans had a number of date systems, the Long Count being the most satisfactory relative to the motion of the earth and sun.

In C++, here are the fundamental routines for converting back and forth.

The Julian Date Count functions can be found here: http://www.philadelphia-reflections.com/blog/1722.htm


void MayanToGregorian (int baktun, int katun, int tun, int uinal, int kin,
		       int& gregorianMonth, int& gregorianDay, int& gregorianYear)
	{
	// Convert a Mayan Long Count date into Gregorian

	// 1. convert Mayan date into days from the Mayan 0 date ... the beginning of their calendar
	// 2. convert Mayan days into a Julian Period Date
	// 3. convert Julian Period Date into Gregorian MM DD YYYY


	// 1. find the total number of Mayan days

	long int totalMayanDays;
	
	totalMayanDays = (baktun * 144000) + (katun * 7200) + (tun * 360) + (uinal * 20) + kin;


	// 2. convert to Julian Period Date (per http://www.pauahtun.org/Calendar/longcount.html)

	long int julianPeriodDate;
	const long int correlationConstant = 584285;

	julianPeriodDate = totalMayanDays + correlationConstant;

	// 3. Convert the Julian Period Date number to Gregorian MM DD YYYY
	
	JulianToGregorian (julianPeriodDate, gregorianMonth, gregorianDay, gregorianYear);
	
	return;
	}


void JulianToMayan (long int julianDateNumber, 
		    int& baktun, int& katun, int& tun, int& uinal, int& kin)
	{
	// Convert a Julian Period Date number to Mayan Long Count date

	const long int kinCount    = 1;		      // 1 kin                          = 1 day
	const long int uinalCount  = 20 * kinCount;   // 1 uinal  = 20 kins             = 20 days
	const long int tunCount    = 18 * uinalCount; // 1 tun    = 18 uinals = 18*20   = 360 days
	const long int katunCount  = 20 * tunCount;   // 1 katun  = 20 tuns   = 20*360  = 7,200 days
	const long int baktunCount = 20 * katunCount; // 1 baktun = 20 katuns = 20*7200 = 144,000 days

	long int totalMayanDays;
	const long int correlationConstant = 584285;
	
	// reverse engineer the Mayan to Julian

	totalMayanDays = (julianDateNumber - correlationConstant) + 1;

	baktun = totalMayanDays / baktunCount;
	totalMayanDays = totalMayanDays % baktunCount;

	katun = totalMayanDays / katunCount;
	totalMayanDays = totalMayanDays % katunCount;

	tun = totalMayanDays / tunCount;
	totalMayanDays = totalMayanDays % tunCount;
	
	uinal = totalMayanDays / uinalCount;
	totalMayanDays = totalMayanDays % uinalCount;

	kin = totalMayanDays / kinCount;
			
	return;
	}

(my thanks to http://centricle.com/tools/html-entities/ for HTML encoding)

(1723)

Please Let Us Know What You Think


(HTML tags provide better formatting)

Because of robot spam we ask you to confirm your comment: we will send you an email containing a link to click. We apologize for this inconvenience but this ensures the quality of the comments. (Your email will not be displayed.)
Thank you.