Jump to content

Template:Age2/doc: Difference between revisions

From We Are Calloway
m 1 revision imported: possible template to calculate age without lua?
m remove unnecessary template references
Line 1: Line 1:
{{Documentation subpage}}
<noinclude>{{Documentation subpage}}</noinclude>
<!-- EDIT TEMPLATE DOCUMENTATION BELOW THIS LINE -->
<!-- EDIT TEMPLATE DOCUMENTATION BELOW THIS LINE -->


This template returns the number(s) of full years between two specified dates. It may return one number (e.g. "50") or two possible numbers (e.g. "50-51") of full years, depending on the given information of the two dates.
This template returns the number(s) of full years between two specified dates. It may return one number (e.g. "50") or two possible numbers (e.g. "50-51") of full years, depending on the given information of the two dates.


The template is especially designed for situations where the day, or day and month, of the two dates is unknown. If the year, month and day are all known, you may use {{tl|Age}} or {{tl|Age nts}} as well.
The template is especially designed for situations where the day, or day and month, of the two dates is unknown. If the year, month and day are all known, you may use {{Age}} or {{Age nts}} as well.


==Usage==
==Usage==
<syntaxhighlight lang="wikitext">{{Age2|<year1(yyyy)>|<month1(mm)>|<day1(dd)>|<year2(yyyy)>|<month2(mm)>|<day2(dd)>|sortable=}}</syntaxhighlight>
<pre>{{Age2|<year1(yyyy)>|<month1(mm)>|<day1(dd)>|<year2(yyyy)>|<month2(mm)>|<day2(dd)>|sortable=}}</pre>
* <code>year1</code>, <code>month1</code>, <code>day1</code> are for the starting date
* <code>year1</code>, <code>month1</code>, <code>day1</code> are for the starting date
* <code>year2</code>, <code>month2</code>, <code>day2</code> are for the ending date
* <code>year2</code>, <code>month2</code>, <code>day2</code> are for the ending date
Line 44: Line 44:
===Note===
===Note===
This template does not check for incorrect input:
This template does not check for incorrect input:
* <code><nowiki>{{age|1980|7|14|1993|6|233}}</nowiki></code> returns "{{age|1980|7|14|1993|6|233}}" (surplus days do not count as extra months)
* <code><nowiki>{{age2|1980|7|14|1993|6|233}}</nowiki></code> returns "{{age2|1980|7|14|1993|6|233}}" (surplus days do not count as extra months)
* <code><nowiki>{{age|1980|7|14|1993|88|14}}</nowiki></code> returns "{{age|1980|7|14|1993|88|14}}" (surplus months do not count as extra years)
* <code><nowiki>{{age2|1980|7|14|1993|88|14}}</nowiki></code> returns "{{age2|1980|7|14|1993|88|14}}" (surplus months do not count as extra years)
{{Esoteric}}
{{Esoteric}}


==See also==
<includeonly>
* [[Wikipedia:Age calculation templates]]
; Age only
* {{tl|Age}} – age based on the number of full years between two dates (or a specified date and current date)
* {{tl|Age nts}} – similar to <nowiki>{{Age}}</nowiki>, but will sort correctly in sortable tables
* {{tl|Age in years and days}} – full years and days between two dates (or a specified date and current date)
* {{tl|Age in days}} – age in days between two dates (or a specified date and current date)
* {{tl|Age as of date}} – current age in years, based on a known age as of a specified date
; Birth, death, age
* {{tl|BirthDeathAge}} – displays birth/death dates and age
* {{tl|Birth date}} – displays the date and related hidden metadata
* {{tl|Birth date and age}} – same as {{tl|Birth date}}, except that "(age ##)" appears after the birth date
* {{tl|Birth date and age2}} – displays birth date, plus age as of a specified date, "(aged ##)" appears after the birth date
* {{tl|Birth year and age}} – year of birth and approximate age
* {{tl|Birth-date and age}} – display birth date and age, accepts dates as text (15 June 1950; June 15, 1950; June 1950; etc.)
* {{tl|Birth based on age as of date}} – displays approximate birth year and current age; used when a dated reference mentions the age of a person as of the date of publication
* {{tl|Death date}} – displays the date and related hidden metadata
* {{tl|Death date and age}} – same as {{tl|Death date}}, except that "(aged ##)" appears after the death date
* {{tl|Death year and age}} – year of death and approximate age at death
* {{tl|Death-date and age}} – display death date and age, accepts date as text (15 June 1950; June 15, 1950; June 1950; etc.)
<includeonly>{{Sandbox other||
<!-- ADD CATEGORIES BELOW THIS LINE -->
<!-- ADD CATEGORIES BELOW THIS LINE -->
[[Category:Date mathematics templates]]
[[Category:Date mathematics templates]]
 
</includeonly>
<!-- ADD INTERWIKIS BELOW THIS LINE -->
[[bn:টেমপ্লেট:Age2]]
}}</includeonly>

Revision as of 12:39, 4 October 2025

This is a template documentation subpage for Template:Age2.
It contains usage information, categories, and other content that is not part of the original template page.

This template returns the number(s) of full years between two specified dates. It may return one number (e.g. "50") or two possible numbers (e.g. "50-51") of full years, depending on the given information of the two dates.

The template is especially designed for situations where the day, or day and month, of the two dates is unknown. If the year, month and day are all known, you may use Template:Age or Template:Age nts as well.

Usage

{{Age2|<year1(yyyy)>|<month1(mm)>|<day1(dd)>|<year2(yyyy)>|<month2(mm)>|<day2(dd)>|sortable=}}
  • year1, month1, day1 are for the starting date
  • year2, month2, day2 are for the ending date
  • year1 and year2 are required
  • month1, month2, day1, day2 are optional, if one or some of them is unknown, it may be omitted, or left blank, or filled in "0", "00", like: {{Age2|2000|7|23|2010||}} or {{Age2|2000|7|23|2010}}; {{Age2|2000|0|0|2010|7|14}} or {{Age2|2000|||2010|7|14}}
  • When entering dates before the Common Era, use astronomical year numbering: 1 BC is represented by 0, 2 BC by -1, 3 BC by -2, etc. For example, to calculate Augustus (23 September 63 BC – 19 August 14 AD)'s age: {{Age2|-62|9|23|14|8|19}} returns "75"
  • "sortable", optional, fill in "yes" to add a hidden key, making it sort correctly in sortable tables: {{Age2|2000|7|23|2010|7||sortable=yes}} returns "Template:Ntsh9-10", whose HTML code is "<span style="display:none">&10000000000000009500000</span>9-10", where it is considered 9.5, making it greater than 9 but less than 10.

Examples

Sortable Example
Click
to
sort
Starting
date
Ending
date
Template:Ntsh9 Template:Date Template:Date
Template:Ntsh10 Template:Date Template:Date
Template:Ntsh9-10 Template:Date Template:Date
  • {{Age2|2000|7|23|2010|7|14}} returns "9"
  • {{Age2|2000|7|23|2010|7|}} returns "9-10" (if day2 >= 23 it'll be 10, otherwise it'll be 9)
  • {{Age2|2000|6|23|2010|7|}} returns "10" (it can only be 10)
  • {{Age2|2000|8|23|2010|7|}} returns "9" (it can only be 9)
  • {{Age2|2000|7||2010|7|}} returns "9-10" (10 and 9 are both possible)

When one of the dates is the first or last day of the month or year:

  • {{Age2|2000|1|1|2010||}} returns "10" (it can only be 10, even if month2 and day2 are both 1)
  • {{Age2|2000|7||2010|7|31}} returns "10" (it can only be 10, even if day1 = 31)
  • {{Age2|2000|7|31|2010|7|}} returns "9-10" (if day2 = 31 it'll be 10, otherwise it'll be 9)
  • {{Age2|2000|2|29|2010|2|}} returns "9" (it can only be 9)
  • {{Age2|2000|2||2010|2|28}} returns "9-10" (if day1 = 29 (2000 is a leap year) it'll be 9, otherwise it'll be 10)

Note

This template does not check for incorrect input:

  • {{age2|1980|7|14|1993|6|233}} returns "12" (surplus days do not count as extra months)
  • {{age2|1980|7|14|1993|88|14}} returns "13" (surplus months do not count as extra years)

Template:Esoteric