Difference between revisions of "Template:Age as of date"
Jump to navigation
Jump to search
blackwiki>Zyxw (similar to Template:Birth based on age as of date but only returns the current age, based on a person's age as of a known date.) |
|||
| Line 1: | Line 1: | ||
| − | <includeonly>{{#ifexpr: {{CURRENTMONTH}}<{{MONTHNUMBER|{{{3}}}}}|{{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}} - 1 }}–{{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}} }} }}{{#ifexpr: {{CURRENTMONTH}}={{MONTHNUMBER|{{{3}}}}}|{{#ifexpr: {{CURRENTDAY}} > {{{4}}} | {{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}} }}–{{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}} + 1}} | {{#ifexpr: {{CURRENTDAY}} = {{{4}}} | {{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}}}} | {{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}} - 1}}–{{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}} }} }} }} }}{{#ifexpr: {{CURRENTMONTH}}>{{MONTHNUMBER|{{{3}}}}}|{{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}} }}–{{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}} + 1 }} }}</includeonly><noinclude> | + | <includeonly>{{#ifexpr:{{CURRENTMONTH}}<{{MONTHNUMBER|{{{3}}}}}|{{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}} - 1 }}–{{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}} }} }}{{#ifexpr: {{CURRENTMONTH}}={{MONTHNUMBER|{{{3}}}}}|{{#ifexpr: {{CURRENTDAY}} > {{{4}}} | {{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}} }}–{{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}} + 1}} | {{#ifexpr: {{CURRENTDAY}} = {{{4}}} | {{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}}}} | {{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}} - 1}}–{{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}} }} }} }} }}{{#ifexpr: {{CURRENTMONTH}}>{{MONTHNUMBER|{{{3}}}}}|{{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}} }}–{{#expr: {{CURRENTYEAR}}-{{{2}}} + {{{1}}} + 1 }} }}</includeonly><noinclude> |
{{documentation}} | {{documentation}} | ||
</noinclude> | </noinclude> | ||
Revision as of 09:45, 21 February 2019
Usage
This template calculates a person's current age based on a known age as of specified date. This is useful when a reference states a person's age at the time of the reference's publication.
{{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 a reference dated July 4, 2023, mentions that someone is 50 years old, that person's current age can be rendered using:
{{Age as of date|50|2023|July|4}}
Examples
| Template text | Result |
|---|---|
| {{Age as of date|50|2023|1|1}} | 52–53 |
| {{Age as of date|50|2023|12|31}} | 52 |
| {{Age as of date|50|2023|12|31}} | 52 |
| {{Age as of date|50|2023|Dec|31}} | 52 |
| {{Age as of date|50|2023|December|31}} | 52 |
See also
| The above documentation is transcluded from Template:Age as of date/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |