Age Action
I haven't seen any actions out there that are useful for determining the age of something provided the start day, month, and year. I'm using this a temporary holding place while I clean up my code and improve some functionality.
This code doesn't quite work yet, but you can see what I'm planning on doing.
Source
- <?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
- // Get the Death/End Dates
- $age = $this_year - $bYear;
- if ($bMonth>$this_month||($this_month==$bMonth&&$this_day<$bDay)) {
- $age--;
- }
- echo $this->ReturnSafeHTML($age);
- ?>