PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.php > Mayan Calendars
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Mayan Calendars

Réponse
 
LinkBack Outils de la discussion
Vieux 27/11/2007, 21h05   #1
Simon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Mayan Calendars

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,2 0,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'=>ab s
($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.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h38.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09278 seconds with 9 queries