Difference between revisions of "Template:Age"

From LGPedia
Jump to: navigation, search
m (See also)
m (Writing over with SimpleAge; it's almost identical to the date template, which is in constant use now, so why not?)
Line 1: Line 1:
<includeonly>{{#expr:({{{4|{{CURRENTYEAR}}}}})-({{{1}}})-(({{{5|{{CURRENTMONTH}}}}})<({{{2}}})or({{{5|{{CURRENTMONTH}}}}})=({{{2}}})and({{{6|{{CURRENTDAY}}}}})<({{{3}}}))}}</includeonly>
+
<includeonly>{{#ifeq: {{#ifexpr: {{{1}}} |true}} | true | {{#ifexpr: ({{{1}}} >= 19700101) and ({{{1}}} <= 20380118) | {{ #expr: {{#time: Y | {{{2|{{CURRENTYEAR}}{{CURRENTMONTH}}{{CURRENTDAY}}}}} }}-{{#time: Y | {{{1}}} }}-{{ #expr: ({{#time: n | {{{2|{{CURRENTYEAR}}{{CURRENTMONTH}}{{CURRENTDAY}}}}} }} < {{#time: n | {{{1}}} }}) or (({{#time: n | {{{2|{{CURRENTYEAR}}{{CURRENTMONTH}}{{CURRENTDAY}}}}} }} = {{#time: n | {{{1}}} }}) and ({{#time: j | {{{2|{{CURRENTYEAR}}{{CURRENTMONTH}}{{CURRENTDAY}}}}} }} < {{#time: j | {{{1}}} }})) }}}} | {{{1|}}} }} | {{{1|}}} }}</includeonly><noinclude>This template returns the number of full years between two specified dates.  If the second set of parameters is not included, it will return the number of full years between a specified date and today's date.
 +
==Usage==
 +
===To current date===
 +
<pre>{{SimpleAge|START DATE}}</pre>
  
<noinclude>
+
===To specific date===
    <!-- EDIT TEMPLATE DOCUMENTATION BELOW THIS LINE -->
+
<pre>{{SimpleAge|START DATE|END DATE}}</pre>
This template returns the number of full years between two specified dates.  If the second set of parameters is not included, it will return the number of full years between a specified date and today's date.
+
  
;Syntax<nowiki>:</nowiki>
+
===Date formatting===
:<nowiki>{{age|year1|month1|day1|year2|month2|day2}}</nowiki>  or
+
Dates have to be formatted year, month, date; zero-padded, no punctuation. If you did it right, you should have a total of eight digits. Christmas Eve 2007 would be formatted as <code>20071224</code>, for example.
:<nowiki>{{age|year1|month1|day1}}</nowiki>
+
  
; Examples<nowiki>:</nowiki>
+
'''For comparison and understanding:'''
: <nowiki>{{age|1989|7|23|2003|7|14}}</nowiki> returns "{{age|1989|7|23|2003|7|14}}"
+
:Today is {{CURRENTDAYNAME}}, {{CURRENTMONTHNAME}} {{CURRENTDAY}}, {{CURRENTYEAR}}.
: <nowiki>{{age|1989|7|23}}</nowiki> returns "{{age|1989|7|23}}"
+
:In digits, this would either be {{CURRENTMONTH}}/{{CURRENTDAY}}/{{CURRENTYEAR}} (US) or {{CURRENTDAY}}/{{CURRENTMONTH}}/{{CURRENTYEAR}} (majority of the world).
 +
:Formatted correctly for the template, it would be {{CURRENTYEAR}}{{CURRENTMONTH}}{{CURRENTDAY}}.
  
: When using this template to calculate a person's age at death or a person's age on a specified date (rather than the person's current age), please substitute it into the page.
+
===Non-dates and illegal dates===
:: Example: <nowiki>{{subst:age|1989|7|23|2003|7|14}}</nowiki>
+
*Due to technical reasons, dates before January 1st, 1970 and after January 18th, 2038 cannot be processed. Input that falls outside of this range will be displayed unchanged.
 
+
*Any non-numerical input will be displayed unprocessed as well.
; Note<nowiki>:</nowiki>
+
[[Category:Templates|{{PAGENAME}}]]</noinclude>
:This template does not check for incorrect input:
+
:: <nowiki>{{age|1980|7|14|1993|6|233}}</nowiki> returns "{{age|1980|7|14|1993|6|233}}" (surplus days do not count as extra months)
+
:: <nowiki>{{age|1980|7|14|1993|88|14}}</nowiki> returns "{{age|1980|7|14|1993|88|14}}" (surplus months do not count as extra years)
+
 
+
</noinclude>
+

Revision as of 15:03, 8 April 2008

This template returns the number of full years between two specified dates. If the second set of parameters is not included, it will return the number of full years between a specified date and today's date.

Usage

To current date

{{SimpleAge|START DATE}}

To specific date

{{SimpleAge|START DATE|END DATE}}

Date formatting

Dates have to be formatted year, month, date; zero-padded, no punctuation. If you did it right, you should have a total of eight digits. Christmas Eve 2007 would be formatted as 20071224, for example.

For comparison and understanding:

Today is Saturday, April 27, 2024.
In digits, this would either be 04/27/2024 (US) or 27/04/2024 (majority of the world).
Formatted correctly for the template, it would be 20240427.

Non-dates and illegal dates

  • Due to technical reasons, dates before January 1st, 1970 and after January 18th, 2038 cannot be processed. Input that falls outside of this range will be displayed unchanged.
  • Any non-numerical input will be displayed unprocessed as well.