note 79079 added to ref.calendar
| From: | simon at chronolabs dot org dot au | Date: | Fri, 09 Nov 2007 19:44:02 +0000 |
| Subject: | note 79079 added to ref.calendar | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132152@lists.php.net to get a copy of this message | ||
This is the egyptian calendar which was the first 365 day calendar on the planet it has no leap year
which makes it a little inaccurate but you can work on your own implementation of this code when you
like, this is another implementation of the roun floating point code which is a universal code for
generating date codec's you can make practically all calendars with this code the $pweight is
based on my research on carbon date stamping etc of when egypt epoch or PPO was made, some people
argue a few thousand years while other can date egypts epoch being around 30000 years ago!! This is
on the basis of tidal marking on statues and momuments when the are was covered in water after
construction from sea level rising.
<?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))
{
// Code Segment 1 â Calculate Floating Point
$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);
// Code Segment 2 â Set month day arrays
$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;
// Code Segment 3 â Calculate month number, day number
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++;
}
}
//$numyears = abs($numyears);
$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;
}
?>
btw in my previous post of the Mayan Tikal calendar the top part of the function was chopped off in
my code cut and paste that is the line for the function which looks like, the top 3 line will need
to be replace with:
<?php
print_r(MayanTikalCalendar(time(),0));
function MayanTikalCalendar($unix_time, $gmt,
?>
----
Server IP: 203.16.234.19
Probable Submitter: 125.253.8.126
----
Manual Page -- http://www.php.net/manual/en/ref.calendar.php
Edit -- https://master.php.net/note/edit/79079
Del: integrated -- https://master.php.net/note/delete/79079/integrated
Del: useless -- https://master.php.net/note/delete/79079/useless
Del: bad code -- https://master.php.net/note/delete/79079/bad+code
Del: spam -- https://master.php.net/note/delete/79079/spam
Del: non-english -- https://master.php.net/note/delete/79079/non-english
Del: in docs -- https://master.php.net/note/delete/79079/in+docs
Del: other reasons-- https://master.php.net/note/delete/79079
Reject -- https://master.php.net/note/reject/79079
Search -- https://master.php.net/manage/user-notes.php