note 77509 added to ref.calendar
| From: | simon at chronolabs dot org dot au | Date: | Sat, 01 Sep 2007 17:10:08 +0000 |
| Subject: | note 77509 added to ref.calendar | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130068@lists.php.net to get a copy of this message | ||
I have reviewed the roun time article in time() function and thought I would send the best described
system for returning the time.
<?php
// Roun Calendar calculations
function rouncalendar($unixtime, $gmt=0){
$tme=$unixtime;
if ($gmt>0){
$gmt=-$gmt;
} else {
$gmt=$gmt+$gmt+$gmt;
}
$ptime = strtotime('2008-05-11 10:05 AM')+(60*60*gmt);
$weight = -20.22222222223+(1*gmt);
$roun_xa = ($tme)/(24*60*60);
$roun_ya = $ptime/(24*60*60);
$roun = (($roun_xa -$roun_ya) - $weight)+(microtime/999999);
$nonedeficient = array("seq1" => array(31,30,31,30,30,30,31,30,31,30,31,30),
"seq2" => array(31,30,31,30,31,30,31,30,31,30,31,30),
"seq3" => array(31,30,31,30,30,30,31,30,31,30,31,30),
"seq4" => array(31,30,31,30,30,30,31,30,31,30,31,30));
$deficient = array("seq1" => array(31,30,31,30,30,30,31,30,31,30,31,30),
"seq2" => array(31,30,31,30,31,30,31,30,31,30,31,30),
"seq3" => array(31,30,31,30,31,30,31,30,30,30,31,30),
"seq4" => array(30,30,31,30,31,30,31,30,31,30,31,30));
$monthusage = isset($_GET['deficiency']) ? ${$_GET['deficiency']} : $deficient;
foreach($monthusage as $key => $item){
$i++;
foreach($item as $numdays){
$ttl_num=$ttl_num+$numdays;
}
}
$revolutionsperyear = $ttl_num / $i;
$numyears = round((round(ceil($roun)) / $revolutionsperyear),0);
$jtl = abs(abs($roun) - ceil($revolutionsperyear*($numyears+1)));
while($month==0){
$day=0;
foreach($monthusage as $key => $item){
$t++;
$u=0;
foreach($item as $numdays){
if ($ii<abs($roun)){
$isbelow=true;
}
$ii=$ii+$numdays;
if ($ii>abs($roun)){
$isabove=true;
}
if ($isbelow==true&&$isabove==true){
$daynum = floor(($ii-$numday)-abs($roun));
$month = $u;
$month++;
$isbelow=false;
$isabove=false;
$nodaycount=true;
}
if ($nodaycount==false)
$day++;
$u++;
}
}
}
$timer = substr($roun, strpos($roun,'.')+1,strlen($roun)-strpos($roun,'.')-1);
$roun_out= $numyears.'-'.$month.
'-'.$daynum.' '.$day.'.'.substr($timer,0,2).':'.
substr($timer,2,2).':'.substr($timer,4,2).'.'.
substr($timer,6,strlen($timer)-6);
$roun_obj = array('year' => $numyears,
'month' => $month,
'day' => $day,
'hour' => substr($timer,0,2),
'minute' => substr($timer,0,4),
'sec' => substr($timer,0,6),
'microtime' => substr($timer,6,strlen($timer)-6),
'daycount' => $day,
'outstr' => $roun_out)
$return $roun_obj;
}
?>
The document for this is at http://time.chronolabs.org.au/roun-time-article.pdf
Thanks!! Some of the other calendars work in the array as well!!
----
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/77509
Del: integrated -- https://master.php.net/note/delete/77509/integrated
Del: useless -- https://master.php.net/note/delete/77509/useless
Del: bad code -- https://master.php.net/note/delete/77509/bad+code
Del: spam -- https://master.php.net/note/delete/77509/spam
Del: non-english -- https://master.php.net/note/delete/77509/non-english
Del: in docs -- https://master.php.net/note/delete/77509/in+docs
Del: other reasons-- https://master.php.net/note/delete/77509
Reject -- https://master.php.net/note/reject/77509
Search -- https://master.php.net/manage/user-notes.php