|
Posted by Simon on 11/27/07 21:05
function MayanTihkalCalendar($unix_time, $gmt, $poffset = '2012-12-21
8:24 PM', $pweight = '-1872000.22222222223', $defiency='nonedeficient',
$timeset= array("hours" => 24, "minutes" => 60, "seconds" => 60))
{
// Code Segment 1 Calculate Floating Point
$tme = $unix_time;
if ($gmt>0){
$gmt=-$gmt;
} else {
$gmt=abs($gmt);
}
$ptime = strtotime($poffset)+(60*60*gmt);
$roun_xa = ($tme)/(24*60*60);
$roun_ya = $ptime/(24*60*60);
$roun = (($roun_xa -$roun_ya) - $pweight)+(microtime/999999);
// Code Segment 2 Set month day arrays
$nonedeficient = array("seq1" => array
(20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,5));
$monthnames = array("seq1" => array('Pop', 'Uo', 'Zip', 'Zot\'z',
'Tzec', 'Xul', 'Yaxkin', 'Mol',
'Ch\'en',
'Yax', 'Zac', 'Ceh', 'Mac', 'Kankin', 'Muan', 'Pax',
'Kayab',
'Cumku', 'Uayeb'));
$daynames = array("seq1" => array('Imix', 'Ik', 'Akbal', 'Kan',
'Chicchan', 'Cimi','Manik', 'Lamat',
'Muluc', 'Oc',
'Chuen', 'Eb', 'Ben', 'Ix', 'Men', 'Cib', 'Caban',
'Etz\'nab',
'Cauac', 'Ahau'));
$monthusage = isset($defiency) ? ${$defiency} : $deficient;
// Code Segment 3 Calculate month number, day number, day count
etc
foreach($monthusage as $key => $item){
$i++;
foreach($item as $numdays){
$ttl_num=$ttl_num+$numdays;
$ttl_num_months++;
}
}
// As well as Function MayanTihkalCalendar
$revolutionsperyear = $ttl_num / $i;
$numyears = floor((ceil($roun) / $revolutionsperyear));
$avg_num_month = $ttl_num_months/$i;
$jtl = abs(abs($roun) - ceil($revolutionsperyear*($numyears+1)));
while($month==0){
$day=0;
$u=0;
foreach($monthusage as $key => $item){
$t=0;
foreach($item as $numdays){
$t++;
$tt=0;
for($sh=1;$sh<=$numdays;$sh++){
$ii=$ii+1;
$tt++;
if ($ii==floor($jtl)){
if ($roun<0){
$daynum = $tt;
$month = $t;
} else {
$daynum = $numdays-($tt-1);
$month = $avg_num_month-($t-
1);
}
$sequence = $key;
$nodaycount=true;
}
}
if ($nodaycount==false)
$day++;
}
$u++;
}
}
//$numyears = abs($numyears);
$timer = substr($roun, strpos($roun,'.')+1,strlen($roun)-strpos
($roun,'.')-1);
$roun_out= $numyears.'/'.$month.'/'.$daynum.' '.$day.'.'. floor
(intval(substr($timer,0,2))/100*$timeset['hours']).':'. floor(intval
(substr($timer,2,2))/100*$timeset['minutes']).':'. floor(intval(substr
($timer,4,2))/100*$timeset['seconds']).'.'.substr($timer,6,strlen
($timer)-6);
$roun_obj = array('longcount'=>MayanLongCount($tme),'year'=>abs
($numyears),'month'=>$month, 'mname' => $monthnames[$sequence][$month-
1],'day'=>$daynum, 'dayname'=>$daynames[$sequence][$daynum-1], 'day'=>
$daynum, 'jtl'=>$jtl, 'day_count'=>$day,'hours'=>floor(intval(substr
($timer,0,2))/100*$timeset['hours']),'minute'=> floor(intval(substr
($timer,2,2))/100*$timeset['minutes']),'seconds'=> floor(intval(substr
($timer,4,2))/100*$timeset['seconds']),'microtime'=>substr
($timer,6,strlen($timer)-6),'strout'=>$roun_out);
return $roun_obj;
}
function MayanLongCount($tme){
$config = array('ppo' => array(13,0,0,0,0),
'epoch' => strtotime('2012-12-21'));
$diff=(($tme-$config['epoch'])/(60*60*24));
$ppo = changemaya($config['ppo'],ceil($diff));
return $ppo[0].'.'.$ppo[1].'.'.$ppo[2].'.'.$ppo[3].'.'.$ppo[4];
}
function changemaya($ppo,$diff){
if ($diff>0) { $amount=1; } else { $amount=-1; }
for ($sh=1;$sh<abs($diff);$sh++){
if ($ppo[4]+$amount>20){
if ($ppo[3]+$amount>20){
if ($ppo[2]+$amount>20){
if ($ppo[1]+$amount>20){
if ($ppo[0]+$amount>20){
$ppo[0]=0;
$ppo[1]=0;
$ppo[2]=0;
$ppo[3]=0;
$ppo[4]=0;
} else {
$ppo[1]=0;
$ppo[0]=$ppo[0]+$amount;
}
} else {
$ppo[2]=0;
$ppo[1]=$ppo[1]+$amount;
}
} else {
$ppo[3]=0;
$ppo[2]=$ppo[2]+$amount;
}
} else {
$ppo[4]=0;
$ppo[3]=$ppo[3]+$amount;
}
} elseif ($ppo[4]+$amount<0){
if ($ppo[3]+$amount<0){
if ($ppo[2]+$amount<0){
if ($ppo[1]+$amount<0){
if ($ppo[0]+$amount<0){
$ppo[0]=20;
$ppo[1]=0;
$ppo[2]=0;
$ppo[3]=0;
$ppo[4]=0;
} else {
$ppo[1]=20;
$ppo[0]=$ppo[0]+$amount;
}
} else {
$ppo[2]=20;
$ppo[1]=$ppo[1]+$amount;
}
} else {
$ppo[3]=20;
$ppo[2]=$ppo[2]+$amount;
}
} else {
$ppo[4]=20;
$ppo[3]=$ppo[3]+$amount;
}
} else {
$ppo[4]=$ppo[4]+$amount;
}
}
return $ppo;
}
--
-----------------------------------------------------------------------
Simon Roberts
Chronolabs Australia
http://www.chronolabs.org.au/
http://www.extraterrestrialembassy.com/
-----------------------------------------------------------------------
Disclaimer: The information transmitted is intended only for the person
or entity to which it is addressed and may contain confidential and / or
privileged material. Any review, transmission, dissemination or other
use of, or taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is prohibited. If
you received this in error, please contact the sender and delete the
material from any computer in your company.
[Back to original message]
|