Revision history for AgeAction


Revision [20598]

Last edited on 2009-05-07 16:12:03 by PezHore
Additions:
This code doesn't quite work yet, but you can see what I'm planning on doing.
%%(php;1)
<?php
/**
* Age Action for Wikka Wiki (http://wikkawiki.org/AgeAction)
*
* Usage:
* {{age}} - Displays usage
* {{age bYear="####" bMonth="##" bDay="##"}} - Calculates current age based on date function
* {{age bYear="####" bMonth="##" bDay="##"
* dYear="####" dMonth="##" dDay="##"}} - Calculates age based on death day
*
* Version 0.1
* @input int $bYear Mandatory: Birth/Start year
* @input int $bMonth Mandatory: Birth/Start month
* @input int $bDay Mandatory: Birth/Start day
* @input int $dYear Optional: Death/End year
* @input int $dMonth Optional: Death/End month
* @input int $dDay Optional: Death/End day
* @output int $age The age provided by either
* current date - birth/start date or death/end date - birth/start date
* @uses Wakka::ReturnSafeHTML()
* @todo Add Death/End Date calculations
*
* Changelog
* 0.1 Initial revision
*/
// Get the Birth/Start dates
$bYear = (int)trim($this->htmlspecialchars_ent($vars['byear']));
$bMonth = (int)trim($this->htmlspecialchars_ent($vars['bmonth']));
$bDay = (int)trim($this->htmlspecialchars_ent($vars['bday']));
// Get the Death/End Dates
$dYear = (int)trim($this->htmlspecialchars_ent($vars['dyear']));
$dMonth = (int)trim($this->htmlspecialchars_ent($vars['dmonth']));
$dDay = (int)trim($this->htmlspecialchars_ent($vars['dday']));
$day=(empty($day))?'1':$day;
list($this_year, $this_month, $this_day) = explode(' ',date('Y n j'));
$age = $this_year - $bYear;
if ($bMonth>$this_month||($this_month==$bMonth&&$this_day<$bDay)) {
$age--;
}
echo $this->ReturnSafeHTML($age);
?>
%%
Deletions:
Coming soon...


Revision [20596]

The oldest known version of this page was created on 2009-05-07 12:23:06 by PezHore
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki