Difference between revisions of "Template:Birth based on age as of date/doc"

From blackwiki
Jump to navigation Jump to search
imported>Zyxw
(→‎Examples: Update examples)
 
(17 intermediate revisions by 10 users not shown)
Line 1: Line 1:
 
{{Documentation subpage}}
 
{{Documentation subpage}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
+
<!-- PLEASE ADD CATEGORIES WHERE INDICATED AT THE BOTTOM OF THIS PAGE -->
{{esoteric}}
+
{{Intricate template}}
=== Usage ===
 
This template calculates the birth year and current age based on the age as of a date. This is useful when a reference states only their age at the time of the reference's publication.
 
  
=== Syntax ===
+
This template calculates a person's birth year and current age based on their age as of a date. This is useful when a [[wp:reliable source|reliable source]] states only their age at the time of publication.
<pre>
 
{{Birth based on age as of date|age|year|month|day}}
 
</pre>
 
  
The age, year, and day must be supplied as [[natural number]]s; month can be specified as a natural number as well as by name or abbreviation (e.g. "August" or "Aug").  The [[Gregorian calendar]] is assumed, with no special support provided for [[dual dating]] or the difference between [[Old Style and New Style dates]] .
+
===Syntax===
 +
<pre> {{birth based on age as of date |age |year|month|day}} </pre>
 +
The age, year, and day must be supplied as [[natural number]]s; month can be specified as a natural number as well as by name or abbreviation (e.g. "August" or "Aug").  The [[Gregorian calendar]] is assumed, with no special support provided for [[dual dating]] or the difference between [[Old Style and New Style dates]].
  
=== Options ===
+
If they are not known, the "day" and "month" fields can be omitted; this is useful if, for example, only the publication year for a source is known.
Suppress the age field:
 
  
<pre>
+
===Options===
{{Birth based on age as of date|age|year|month|day|noage=1}}
+
To suppress the age field:
</pre>
+
<pre> {{birth based on age as of date |age |year|month|day |noage=1}} </pre>
  
 
With the "noage=1" option, the month and day can be "1".
 
With the "noage=1" option, the month and day can be "1".
  
=== Examples===
+
To replace the '/' separator with ' or ' in compliance with [[WP:APPROXDATE]], add {{para|mos|1}}
For example, if a reference dated July 4, {{#expr: {{CURRENTYEAR}} - 1}} mentions that someone is 50 years old, that person's birth year and age can be rendered using
+
:<code><nowiki>{{birth based on age as of date|50 |</nowiki>{{#expr:{{CURRENTYEAR}}-1}}|{{CURRENTMONTH}}|{{CURRENTDAY}}|mos=1}}</code>
<nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|July|4}}
+
::{{birth based on age as of date|50 |{{#expr:{{CURRENTYEAR}}-1}}|{{CURRENTMONTH}}|{{CURRENTDAY}}|mos=1}}
  
{| class="wikitable plainlinksneverexpand noprint" style="margin-top:0; width:100%; text-align:center;"
+
===Examples===
 +
If, for example, a reference dated July 4, {{#expr:{{CURRENTYEAR}}-1}} mentions that someone is 50 years old, that person's birth year and age can be rendered using:
 +
<nowiki>{{birth based on age as of date |50 |</nowiki>{{#expr:{{CURRENTYEAR}}-1}}|July|4}}
 +
 
 +
{| class="plainlinksneverexpand" style="margin-top:0;"
 +
!style="border:1px solid #aaa;background:#dfd;"|
 +
The following examples are for a person reported as being 50 years old in {{#expr:{{CURRENTYEAR}}-1}}
 
|-
 
|-
! colspan="6" style="background:#dfd;"|
+
|
The following examples use a date which is one year before:
+
{{Aligned table
{{CURRENTDAY}}&nbsp;{{CURRENTMONTHNAME}}&nbsp;{{CURRENTYEAR}}
+
  |class=wikitable |colstyle=padding-right:1.0em;
|}
+
  |col1style=font-family:monospace;padding-right:1.0em;
 +
  |row1header=on| {{sans-serif|Template code}} | Result
 +
 
 +
  | {{braces|birth based on age as of date|50 |{{#expr:{{CURRENTYEAR}}-1}}|{{CURRENTMONTH}}|{{CURRENTDAY}}}}
 +
  |        {{birth based on age as of date|50 |{{#expr:{{CURRENTYEAR}}-1}}|{{CURRENTMONTH}}|{{CURRENTDAY}}}}
 +
 
 +
  | {{braces|birth based on age as of date|50 |{{#expr:{{CURRENTYEAR}}-1}}|{{CURRENTMONTHNAME}}|{{CURRENTDAY}}}}
 +
  |        {{birth based on age as of date|50 |{{#expr:{{CURRENTYEAR}}-1}}|{{CURRENTMONTHNAME}}|{{CURRENTDAY}}}}
 +
 
 +
  | {{braces|birth based on age as of date|50 |{{#expr:{{CURRENTYEAR}}-1}}|12|31}}
 +
  |        {{birth based on age as of date|50 |{{#expr:{{CURRENTYEAR}}-1}}|12|31}}
 +
 
 +
  | {{braces|birth based on age as of date|50 |{{#expr:{{CURRENTYEAR}}-1}}|Jan|1}}
 +
  |        {{birth based on age as of date|50 |{{#expr:{{CURRENTYEAR}}-1}}|Jan|1}}
 +
 
 +
  | {{braces|birth based on age as of date|50 |{{#expr:{{CURRENTYEAR}}-1}}|12|31|noage{{=}}1}}
 +
  |        {{birth based on age as of date|50 |{{#expr:{{CURRENTYEAR}}-1}}|12|31|noage=1}}
 +
 
 +
  | {{braces|birth based on age as of date|50|{{#expr:{{CURRENTYEAR}}-1}}|Jan|1|noage{{=}}1}}
 +
  |        {{birth based on age as of date|50|{{#expr:{{CURRENTYEAR}}-1}}|Jan|1|noage=1}}
 +
 
 +
  | {{braces|birth based on age as of date|50|{{#expr:{{CURRENTYEAR}}-1}}|{{CURRENTMONTHNAME}}}}
 +
  |        {{birth based on age as of date|50|{{#expr:{{CURRENTYEAR}}-1}}|{{CURRENTMONTHNAME}}}}
 +
 
 +
  | {{braces|birth based on age as of date|50|{{#expr:{{CURRENTYEAR}}-1}}|Jan}}
 +
  |        {{birth based on age as of date|50|{{#expr:{{CURRENTYEAR}}-1}}|Jan}}
 +
 
 +
  | {{braces|birth based on age as of date|50|{{#expr:{{CURRENTYEAR}}-1}}|12}}
 +
  |       {{birth based on age as of date|50|{{#expr:{{CURRENTYEAR}}-1}}|12}}
  
{| class=wikitable width=100%
+
  | {{braces|birth based on age as of date|50|{{#expr:{{CURRENTYEAR}}-1}}}}
|-
+
  |       {{birth based on age as of date|50|{{#expr:{{CURRENTYEAR}}-1}}}}
! width=70% | Template text
+
  }}
! width=30% | Result
 
|-
 
| align=center | <tt><nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|{{#expr: {{CURRENTMONTH}}}}|{{CURRENTDAY}}}}</tt>
 
| align=center | {{Birth based on age as of date|50|{{#expr: {{CURRENTYEAR}} - 1}}|{{CURRENTMONTH}}|{{CURRENTDAY}}}}
 
|-
 
| align=center | <tt><nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|{{CURRENTMONTHNAME}}|{{CURRENTDAY}}}}</tt>
 
| align=center | {{Birth based on age as of date|50|{{#expr: {{CURRENTYEAR}} - 1}}|{{CURRENTMONTH}}|{{CURRENTDAY}}}}
 
|-
 
| align=center | <tt><nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|12|31}}</tt>
 
| align=center | {{Birth based on age as of date|50|{{#expr: {{CURRENTYEAR}} - 1}}|12|31}}
 
|-
 
| align=center | <tt><nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|Jan|1}}</tt>
 
| align=center | {{Birth based on age as of date|50|{{#expr: {{CURRENTYEAR}} - 1}}|Jan|1}}
 
|-
 
| align=center | <tt><nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|12|31|noage=1}}</tt>
 
| align=center | {{Birth based on age as of date|50|{{#expr: {{CURRENTYEAR}} - 1}}|12|31|noage=1}}
 
|-
 
| align=center | <tt><nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|Jan|1|noage=1}}</tt>
 
| align=center | {{Birth based on age as of date|50|{{#expr: {{CURRENTYEAR}} - 1}}|Jan|1|noage=1}}
 
|-
 
 
|}
 
|}
  
=== See also ===
+
{{Birth, death and age templates |BDA}}
* [[Wikipedia:Age calculation templates]]
 
{{Birth, death and age templates}}
 
<includeonly>
 
<!--PLEASE ADD CATEGORIES AND INTERWIKIS BELOW THIS LINE. THANKS.-->
 
 
 
[[Category:Date mathematics templates|{{PAGENAME}}]]
 
  
</includeonly>
+
<includeonly>{{Sandbox other|
 +
| <!--PLEASE ADD CATEGORIES BELOW THIS LINE: -->
 +
[[Category:Date mathematics templates]]
 +
}}</includeonly>
 +
<templatedata>
 +
{
 +
"params": {
 +
"1": {
 +
"label": "Age",
 +
"description": "Age of subject at date of reference's publication.",
 +
"example": "55",
 +
"type": "number",
 +
"required": true
 +
},
 +
"2": {
 +
"label": "Year",
 +
"description": "Year of publication of reference.",
 +
"example": "1950",
 +
"type": "number",
 +
"required": true
 +
},
 +
"3": {
 +
"label": "Month",
 +
"description": "Month of publication of reference.",
 +
"example": "8 or August",
 +
"type": "string",
 +
"suggested": true
 +
},
 +
"4": {
 +
"label": "Day",
 +
"description": "Day of publication of reference.",
 +
"example": "21",
 +
"type": "number",
 +
"suggested": true
 +
},
 +
"mos": {
 +
"label": "MOS compliance",
 +
"description": "Set to a value of 1 to replace the '/' separator with ' or ' in compliance with [[WP:APPROXDATE]].",
 +
"example": "1",
 +
"type": "number"
 +
},
 +
"noage": {
 +
"label": "Hide age",
 +
"description": "Set to a value of 1 to display year of birth without the age.",
 +
"example": "1",
 +
"type": "number"
 +
}
 +
},
 +
"description": "This template calculates the birth year and current age based on the age as of a date.",
 +
"format": "inline"
 +
}
 +
</templatedata>

Latest revision as of 00:37, 19 June 2020

This template calculates a person's birth year and current age based on their age as of a date. This is useful when a reliable source states only their age at the time of publication.

Syntax

 {{birth based on age as of date |age |year|month|day}} 

The age, year, and day must be supplied as natural numbers; month can be specified as a natural number as well as by name or abbreviation (e.g. "August" or "Aug"). The Gregorian calendar is assumed, with no special support provided for dual dating or the difference between Old Style and New Style dates.

If they are not known, the "day" and "month" fields can be omitted; this is useful if, for example, only the publication year for a source is known.

Options

To suppress the age field:

 {{birth based on age as of date |age |year|month|day |noage=1}} 

With the "noage=1" option, the month and day can be "1".

To replace the '/' separator with ' or ' in compliance with WP:APPROXDATE, add |mos=1

{{birth based on age as of date|50 |2025|01|19|mos=1}}
1974 or 1975 (age 51)

Examples

If, for example, a reference dated July 4, 2025 mentions that someone is 50 years old, that person's birth year and age can be rendered using:

{{birth based on age as of date |50 |2025|July|4}}

The following examples are for a person reported as being 50 years old in 2025

Script error: No such module "aligned table".


This template calculates the birth year and current age based on the age as of a date.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Age1

Age of subject at date of reference's publication.

Example
55
Numberrequired
Year2

Year of publication of reference.

Example
1950
Numberrequired
Month3

Month of publication of reference.

Example
8 or August
Stringsuggested
Day4

Day of publication of reference.

Example
21
Numbersuggested
MOS compliancemos

Set to a value of 1 to replace the '/' separator with ' or ' in compliance with [[WP:APPROXDATE]].

Example
1
Numberoptional
Hide agenoage

Set to a value of 1 to display year of birth without the age.

Example
1
Numberoptional