Difference between revisions of "Template:Age in years"
Jump to navigation
Jump to search
blackwiki>WOSlinker (having a range makes more sense) |
blackwiki>Jonesey95 (Sync from sandbox. Add error checking, check for zero age and display 0 instead of -1-0.) |
||
| Line 1: | Line 1: | ||
| − | {{#expr:{{age|{{{1|0}}}|{{CURRENTMONTH}}|{{CURRENTDAY}}|{{{2|{{CURRENTYEAR}}}}}}}-1}}–{{age|{{{1|0}}}|{{CURRENTMONTH}}|{{CURRENTDAY}}|{{{2|{{CURRENTYEAR}}}}}}}<noinclude>{{doc}}</noinclude> | + | {{#ifeq: {{{1}}} | {{{2|{{CURRENTYEAR}}}}} |0|{{#expr:{{age|{{{1|0}}}|{{CURRENTMONTH}}|{{CURRENTDAY}}|{{{2|{{CURRENTYEAR}}}}}}}-1}}–{{age|{{{1|0}}}|{{CURRENTMONTH}}|{{CURRENTDAY}}|{{{2|{{CURRENTYEAR}}}}}}}}}<!-- Error checks: -->{{#if:{{{1|}}}|{{#ifexpr: {{{1}}} > {{{2|{{CURRENTYEAR}}}}} |
| + | |  {{error|invalid year}}{{main other|[[Category:Pages using age template with invalid date]]}}}}|}}<noinclude>{{doc}}</noinclude> | ||
Revision as of 05:02, 2 June 2015
2025–2026
| This template is used on approximately 3,300 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them.
Transclusion count updated automatically (see documentation). |
| This template uses Lua: |
Usage
{{Age in years|2000}} yields 25–26. {{Age in years|1900|1950}} yields 49–50.
Note that the template provides an age range: during the year 2015, someone born in 2000 is either 14 or 15 years old, depending on whether they have passed their birth date in the later year.
See also
| The above documentation is transcluded from Template:Age in years/doc. (edit | history) Editors can experiment in this template's sandbox (edit | diff) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |