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

From blackwiki
Jump to navigation Jump to search
imported>WOSlinker
(tidy style)
imported>Sardanaphalus
(some formatting (including <tt> replacement), sandbox non-categorisation)
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.  
 
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 ===
+
===Syntax===
<pre>
+
<pre> {{Birth based on age as of date|age|year|month|day}} </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]] .
 
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 ===
+
===Options===
Suppress the age field:
+
To suppress the age field:
 
+
<pre> {{Birth based on age as of date|age|year|month|day|noage=1}} </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===
+
===Examples===
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  
+
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}}
 
  <nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|July|4}}
  
{| class="wikitable plainlinksneverexpand noprint" style="margin-top:0; width:100%; text-align:center;"
+
{| class="wikitable plainlinksneverexpand noprint" style="margin-top:0;width:100%;text-align:center;"
|-
 
 
! colspan="6" style="background:#dfd;"|
 
! colspan="6" style="background:#dfd;"|
 
The following examples use a date which is one year before:
 
The following examples use a date which is one year before:
Line 32: Line 25:
 
|}
 
|}
  
{| class=wikitable width=100%
+
{| class="wikitable" style="width:100%;text-align:center;
|-
+
!style="width:70%;"| Template text !! Result
! width=70% | Template text
 
! width=30% | Result
 
|-
 
| style="text-align:center;" | <tt><nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|{{#expr: {{CURRENTMONTH}}}}|{{CURRENTDAY}}}}</tt>
 
| style="text-align:center;" | {{Birth based on age as of date|50|{{#expr: {{CURRENTYEAR}} - 1}}|{{CURRENTMONTH}}|{{CURRENTDAY}}}}
 
 
|-
 
|-
| style="text-align:center;" | <tt><nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|{{CURRENTMONTHNAME}}|{{CURRENTDAY}}}}</tt>
+
| <kbd> <nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|{{#expr: {{CURRENTMONTH}}}}|{{CURRENTDAY}}}} </kbd>
| style="text-align:center;" | {{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}}}}
 
|-
 
|-
| style="text-align:center;" | <tt><nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|12|31}}</tt>
+
| <kbd> <nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|{{CURRENTMONTHNAME}}|{{CURRENTDAY}}}} </kbd>
| style="text-align:center;" | {{Birth based on age as of date|50|{{#expr: {{CURRENTYEAR}} - 1}}|12|31}}
+
| {{Birth based on age as of date|50|{{#expr: {{CURRENTYEAR}} - 1}}|{{CURRENTMONTH}}|{{CURRENTDAY}}}}
 
|-
 
|-
| style="text-align:center;" | <tt><nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|Jan|1}}</tt>
+
| <kbd> <nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|12|31}} </kbd>
| style="text-align:center;" | {{Birth based on age as of date|50|{{#expr: {{CURRENTYEAR}} - 1}}|Jan|1}}
+
| {{Birth based on age as of date|50|{{#expr: {{CURRENTYEAR}} - 1}}|12|31}}
 
|-
 
|-
| style="text-align:center;" | <tt><nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|12|31|noage=1}}</tt>
+
| <kbd> <nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|Jan|1}} </kbd>
| style="text-align:center;" | {{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}}|Jan|1}}
 
|-
 
|-
| style="text-align:center;" | <tt><nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|Jan|1|noage=1}}</tt>
+
| <kbd> <nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|12|31|noage=1}} </kbd>
| style="text-align:center;" | {{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}}|12|31|noage=1}}
 
|-
 
|-
 +
| <kbd> <nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|Jan|1|noage=1}} </kbd>
 +
| {{Birth based on age as of date|50|{{#expr: {{CURRENTYEAR}} - 1}}|Jan|1|noage=1}}
 
|}
 
|}
  
=== See also ===
+
===See also===
 
* [[Wikipedia:Age calculation templates]]
 
* [[Wikipedia:Age calculation templates]]
 +
 
{{Birth, death and age templates}}
 
{{Birth, death and age templates}}
<includeonly>
 
<!--PLEASE ADD CATEGORIES AND INTERWIKIS BELOW THIS LINE. THANKS.-->
 
  
 +
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox |
 +
<!--PLEASE ADD CATEGORIES BELOW THIS LINE: -->
 
[[Category:Date mathematics templates]]  
 
[[Category:Date mathematics templates]]  
 
+
}}</includeonly>
</includeonly>
 

Revision as of 09:54, 7 December 2014

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

 {{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 .

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".

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 use a date which is one year before: 19 January 2026

Template text Result
1|19}} 1974/1975 (age 51)
January|19}} 1974/1975 (age 51)
12|31}} 1974/1975 (age 50–51)
Jan|1}} 1974/1975 (age 51–52)
12|31|noage=1}} 1974/1975
Jan|1|noage=1}} 1974/1975

See also