note 79046 added to ref.calendar
| From: | simon at chronolabs dot org dot au | Date: | Thu, 08 Nov 2007 06:00:11 +0000 |
| Subject: | note 79046 added to ref.calendar | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132101@lists.php.net to get a copy of this message | ||
This will return the mayan long count calendar which cycle reaches 13.0.0.0.0 in 2012, I have had to
compress the changemaya function for this code library so if you want to space it out your more than
welcome. It works with unix time. To call the routine use the following syntax. The mayan calendar
is a day count that is around 5000 years old, it tracks our cestial position in the galaxy
<?php
echo MayanLongCount(time());
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;
}
?>
Thanks!!
----
Server IP: 203.202.10.60
Probable Submitter: 125.253.8.126
----
Manual Page -- http://www.php.net/manual/en/ref.calendar.php
Edit -- https://master.php.net/note/edit/79046
Del: integrated -- https://master.php.net/note/delete/79046/integrated
Del: useless -- https://master.php.net/note/delete/79046/useless
Del: bad code -- https://master.php.net/note/delete/79046/bad+code
Del: spam -- https://master.php.net/note/delete/79046/spam
Del: non-english -- https://master.php.net/note/delete/79046/non-english
Del: in docs -- https://master.php.net/note/delete/79046/in+docs
Del: other reasons-- https://master.php.net/note/delete/79046
Reject -- https://master.php.net/note/reject/79046
Search -- https://master.php.net/manage/user-notes.php