這是埃及曆法,它是地球上第一個 365 天的曆法,它沒有閏年,這使得它有點不準確,但你可以在你喜歡的時候修改這個程式碼,這是另一個 roun 浮點程式碼的實現,這是一個用於產生日期編解碼器的通用程式碼,你幾乎可以用這個程式碼製作所有日曆,$pweight 是基於我對埃及紀元或 PPO 碳定年的研究,有些人認為是幾千年,而其他人則認為埃及紀元大約在 30000 年前!!這是基於雕像和紀念碑上的潮汐標記,當該區域在建造後因海平面上升而被水覆蓋時。
<?php
print_r(EgyptCalendar(time(),0));
function EgyptianCalendar($unix_time, $gmt,
$poffset = '1970-02-26 7:45 PM',
$pweight = '-9777600.22222222223',
$defiency='nonedeficient',
$timeset= array("hours" => 24,
"minutes" => 60,
"seconds" => 60))
{
$tme = $unix_time;
if ($gmt>0){$gmt=-$gmt;} else {$gmt=abs($gmt);}
$ptime = strtotime($poffset)+(60*60*gmt);
$weight = $pweight+(1*gmt);
$egypt_xa = ($tme)/(24*60*60);
$egypt_ya = $ptime/(24*60*60);
$egypt = (($egypt_xa -$egypt_ya) -
$weight)+(microtime/999999);
$nonedeficient = array(
"seq1" => array(30,30,30,30,30,30,30,30,30,30,30,30,5));
$monthnames = array(
"seq1" => array('Thoth','Phaophi','Athyr','Choiak',
'Tybi', 'Mecheir','Phamenoth','Pharmuthi','Pachon',
'Payni','Epiphi','Mesore','epagomenai'));
$monthusage = isset($defiency) ? ${$defiency} : $deficient;
foreach($monthusage as $key => $item){
$i++;
foreach($item as $numdays){
$ttl_num=$ttl_num+$numdays;
$ttl_num_months++;
}
}
$revolutionsperyear = $ttl_num / $i;
$numyears = egyptd((floor($egypt) / $revolutionsperyear),0);
$avg_num_month = $ttl_num_months/$i;
$jtl = abs(abs($egypt) -
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 ($egypt>0){
$daynum = $tt;
$month = $t;
} else {
$daynum = $numdays-$tt;
$month = $avg_num_month-$t;
}
$sequence = $key;
$nodaycount=true;
}
}
if ($nodaycount==false)
$day++;
}
$u++;
}
}
$timer = substr($egypt, strpos($egypt,'.')+1,
strlen($egypt)-strpos($egypt,'.')-1);
$egypt_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);
$egypt_obj = array('year'=>$numyears,
'month'=>$month,
'mname' => $monthnames[$sequence][$month-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'=>$egypt_out);
return $egypt_obj;
}
?>
順便說一下,在我之前發布的瑪雅蒂卡爾曆法中,函式的頂部在我的程式碼複製貼上中被截斷了,也就是函式的程式碼行,看起來像,前三行需要替換為
<?php
print_r(MayanTikalCalendar(time(),0));
函式 MayanTikalCalendar($unix_time, $gmt,
?>