Difference between revisions of "Template:Birth based on age as of date/doc"
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 | + | <!-- PLEASE ADD CATEGORIES WHERE INDICATED AT THE BOTTOM OF THIS PAGE --> |
| − | {{ | + | {{Intricate template}} |
| − | + | ||
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=== |
| − | + | 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=== |
| − | + | 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 | + | {| class="wikitable" style="width:100%;text-align:center; |
| − | + | !style="width:70%;"| Template text !! Result | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
|- | |- | ||
| − | + | | <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}} | ||
|} | |} | ||
| − | === See also === | + | ===See also=== |
* [[Wikipedia:Age calculation templates]] | * [[Wikipedia:Age calculation templates]] | ||
| + | |||
{{Birth, death and age templates}} | {{Birth, death and age templates}} | ||
| − | |||
| − | |||
| + | <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
| File:Edit-copy green.svg | This is a documentation subpage for Template:Birth based on age as of date. It contains usage information, categories and other content that is not part of the original template page. |
| 40x40px | This template employs intricate features of template syntax.
You are encouraged to familiarise yourself with its setup and parser functions before editing the template. If your edit causes unexpected problems, please undo it quickly, as this template may appear on a large number of pages. You can conduct experiments, and should test all major changes, in either this template's sandbox, the general template sandbox, or your user space before changing anything here. |
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.
Contents
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}}
| 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