Welcome, guest | Sign In | My Account | Store | Cart

Calculating Mayan Long Dates from Julian Day Counts.

PHP, 53 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php

/**
 * JDToLongDate
 * $julianday is the julian day count, NOT a julian calendar date
 * $corresponder must be one of the numbers from the above list
 * returns a string containing a mayan day count
 */
function JDToLongDate($julianday,$corresponder){
	$JDA = $julianday - $corresponder;
        
	$bactuns = IntVal($JDA/144000);
        $JDA -= $bactuns * 144000;
        
	$katuns = IntVal($JDA/7200);
        $JDA -= $katuns * 7200;
        
	$tuns = IntVal($JDA/360);
        $JDA -= $tuns * 360;
        
	$uinals = IntVal($JDA/20);

        $kins = $JDA - ($uinals * 20);
	
	$longdate = "$bactuns.$katuns.$tuns.$uinals.$kins";
	
	return $longdate;
}

/**
 * LongDateToJD
 * $longdate is a mayan longdate as returned by JDToLongDate
 * $corresponder must be one of the numbers from the above list
 * returns a julian day count (NOT a julian calendar date)
 */
function LongDateToJD($longdate,$corresponder){
	list($bactuns,$katuns,$tuns,$uinals,$kins)=explode('.',$longdate);
	$daycount = ($bactuns * 144000) + ($katuns * 7200) + ($tuns * 360) + ($uinals * 20) + $kins;
	$julian = $daycount + $corresponder;
	return ($julian);
}


/* example usage */
$julian = GregorianToJD(12,31,2000);
$lc = JDToLongDate($julian,584283);
$jd = LongDateToJD($lc, 584283);
$date = JDToGregorian($jd);

echo "$lc = $date<br>\n";

// outputs 12.19.7.15.7 = 12/31/2000
?>

Conversions use a 'corresponder' number (or correlation) which is an 'anchor' to tie a specific date on the aztec/mayan calendar to a specific date on the julian calendar. various researchers differ in what the correct corresponding date is. Here are many common correlations that can be used. GMT is commonly used.

Smiley - 482699
Makemson - 489138
Spinden - 489384
GMT - 584283
Kriechgauer - 626927
Hochleitner - 674265
Escalona Ramos - 679108
Weitzel - 774078

For further reference there is a good site on the calendar at http://www.azteccalendar.com/

Created by Shane Caraveo on Fri, 7 Dec 2001 (MIT)
PHP recipes (51)
Shane Caraveo's recipes (5)

Required Modules

  • (none specified)

Other Information and Tasks