Extension:Age

What can this extension do?
This extension calculates the number of years, months, and days between two dates (FROM and TO attributes). The extension does not use any PHP built-in functions so it can calculate an answer for dates before 1970. The purpose of this extension is to automatically calculate the difference between two dates. It is useful in historical or genealogical research sites since the author only needs to know the two dates and how he or she wants to show that information; the tag automatically calculates the difference.

Usage
Only the FROM and TO attributes are (usually) required. All other attributes are optional. The &lt;age&gt; tag is used in-line with text on the page so the calculated age becomes part of the sentence, list, etc.

Syntax
Any text within the &lt;age&gt;&lt;/age&gt; tags is ignored (e.g. &lt;age&gt;ignored&lt;/age&gt;).

Attributes
Of the attributes below FROM and TO are required if $wgAgeDefaultToday is FALSE; otherwise, these attributes are optional. All other attributes are optional.


 * ISO formatted starting date
 * Only optional if $wgAgeDefaultToday = TRUE


 * ISO formatted ending date
 * Only optional if $wgAgeDefaultToday = TRUE


 * Optional text to prepend (add to left) of answer
 * Most commonly "(" to enclose answer in parenthesis


 * Optional text to append (add to right) of answer
 * Most commonly ")" to enclose answer in parenthesis


 * Controls how much of answer to show
 * ymd = X years, Y months, Z days
 * ym = X years, Y months (days are not shown)
 * y = X years (months and days are not shown
 * Defaults to "ymd"


 * Controls if error box appears (if, of course, there is an error)
 * Overrides $wgAgeErrorBox

Download instructions
Copy and paste the code found below and place it in a file called. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Copy and paste the language code found below and place it in a file called.

Installation
To install this extension, add the following to LocalSettings.php:

Configuration parameters
The following settings can be added to LocalSettings.php:
 * TRUE = show any errors using the 'errorbox' CSS format (usually a red box)
 * FALSE = show errors in-line with the page content
 * Not set in LocalSettings.php defaults to FALSE
 * This site-wide setting can be overridden using the 'errbox' attribute


 * TRUE = automatically use current date if either FROM or TO attributes are not specified
 * Set this value then include FROM value in tag to calculate time between that date and the current date
 * Set this value then include TO value in tag to calculate time between current date and a future date (like a count down)
 * FALSE = FROM and TO values are required but will not default to the current date
 * Not set in LocalSettings.php defaults to FALSE

Code
Create a file called extensions/Age/Age.php and copy the following text into it. Be sure to add  and   before and after this text, respectively.

Language
Create a file called extensions/Age/Age.i18n.php and copy the following text into it. Be sure to add  and   before and after this text, respectively. Note that this tag needs additional translations.