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

From blackwiki
Jump to navigation Jump to search
imported>Sardanaphalus
(some formatting (including <tt> replacement), sandbox non-categorisation)
imported>Sardanaphalus
(→‎Examples: Aligned table)
Line 16: Line 16:
  
 
===Examples===
 
===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  
+
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="plainlinksneverexpand" style="margin-top:0;"
! colspan="6" style="background:#dfd;"|
+
!style="border:1px solid #aaa;background:#dfd;"|
The following examples use a date which is one year before:
+
The following examples use a date which is one year before {{CURRENTDAY}}&nbsp;{{CURRENTMONTHNAME}}&nbsp;{{CURRENTYEAR}}
{{CURRENTDAY}}&nbsp;{{CURRENTMONTHNAME}}&nbsp;{{CURRENTYEAR}}
+
|-
|}
+
| {{Aligned table
 +
  |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}}
  
{| class="wikitable" style="width:100%;text-align:center;
+
  | {{braces|Birth based on age as of date |50 |{{#expr:{{CURRENTYEAR}}-1}}|Jan|1 |noage=1}}
!style="width:70%;"| Template text !! Result
+
  |       {{Birth based on age as of date |50 |{{#expr:{{CURRENTYEAR}}-1}}|Jan|1 |noage=1}}
|-
+
  }}
| <kbd> <nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|{{#expr: {{CURRENTMONTH}}}}|{{CURRENTDAY}}}} </kbd>
 
| {{Birth based on age as of date|50|{{#expr: {{CURRENTYEAR}} - 1}}|{{CURRENTMONTH}}|{{CURRENTDAY}}}}
 
|-
 
| <kbd> <nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|{{CURRENTMONTHNAME}}|{{CURRENTDAY}}}} </kbd>
 
| {{Birth based on age as of date|50|{{#expr: {{CURRENTYEAR}} - 1}}|{{CURRENTMONTH}}|{{CURRENTDAY}}}}
 
|-
 
| <kbd> <nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|12|31}} </kbd>
 
| {{Birth based on age as of date|50|{{#expr: {{CURRENTYEAR}} - 1}}|12|31}}
 
|-
 
| <kbd> <nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|Jan|1}} </kbd>
 
| {{Birth based on age as of date|50|{{#expr: {{CURRENTYEAR}} - 1}}|Jan|1}}
 
|-
 
| <kbd> <nowiki>{{Birth based on age as of date|50|</nowiki>{{#expr: {{CURRENTYEAR}} - 1}}|12|31|noage=1}} </kbd>
 
| {{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}}
 
 
|}
 
|}
  

Revision as of 10:18, 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

Script error: No such module "aligned table".

See also