Template:AgeFull: Difference between revisions
Jump to navigation
Jump to search
(existing code from WP's template "How long ago", formatted for readability, but with extant bugs) |
m (original template name has changed to something that's actually logical) |
||
(9 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{ | <includeonly>{{#if:{{{year|}}} | ||
| | |{{#if:{{{month|}}} | ||
{{# | |{{#if:{{{day|}}} | ||
|{{AgeFull/display | |||
|years={{#expr:{{CURRENTYEAR}}-{{{year}}}-{{#ifexpr:{{CURRENTMONTH}}>{{{month}}} | |||
|0 | |||
|{{#ifexpr:{{CURRENTMONTH}}<{{{month}}} | |||
|1 | |||
|{{#ifexpr:{{CURRENTDAY}}>={{{day}}} | |||
|0 | |||
|1 | |||
}} | |||
}} | |||
}}}} | |||
|months={{#expr:{{CURRENTMONTH}}-{{{month}}}+{{#ifexpr:{{CURRENTDAY}}>={{{day}}} | |||
|{{#ifexpr:{{CURRENTMONTH}}>={{{month}}} | |||
|0 | |||
| | |12 | ||
}} | |||
|{{#ifexpr:{{CURRENTMONTH}}>{{{month}}} | |||
|-1 | |||
|11 | |||
}} | |||
}}}} | |||
|days={{#ifexpr:{{CURRENTDAY}}>={{{day}}} | |||
| | |{{#expr:{{CURRENTDAY}}-{{{day}}} | ||
{{#expr:{{ | }} | ||
|{{#expr:{{Gsd | |||
|year={{CURRENTYEAR}} | |||
|month={{CURRENTMONTH}} | |||
|day={{CURRENTDAY}}}}-{{Gsd | |||
|year={{CURRENTYEAR}} | |||
|month={{#expr:{{CURRENTMONTH}}-1}} | |||
|day={{{day}}} | |||
}}}} | |||
}} | |||
}} | }} | ||
|{{#ifexpr:{{CURRENTMONTH}}={{{month}}} | |||
|{{#ifexpr:{{CURRENTYEAR}}={{{year}}} | |||
| | |0 years | ||
{{#ifexpr: | |{{#expr:{{CURRENTYEAR}}-{{{year}}}-1}} or {{AgeFull/display | ||
|years={{#expr:{{CURRENTYEAR}}-{{{year}}}}} | |||
}} | |||
}} | |||
|{{#ifexpr:{{CURRENTMONTH}}>{{{month}}} | |||
|{{#ifexpr:{{CURRENTYEAR}}={{{year}}} | |||
|<!--null value--> | |||
|{{AgeFull/display | |||
|years={{#expr:{{CURRENTYEAR}}-{{{year}}}}} | |||
}} and | |||
}} {{#expr:{{CURRENTMONTH}}-{{{month}}}-1}} or {{AgeFull/display | |||
|months={{#expr:{{CURRENTMONTH}}-{{{month}}}}} | |||
| | |||
}} | |||
| | |||
{{#ifexpr: | |||
| | |||
}} | }} | ||
|{{#ifexpr:{{CURRENTYEAR}}={{#expr:{{{year}}}+1}} | |||
|<!--null value--> | |||
|{{AgeFull/display | |||
|years={{#expr:{{CURRENTYEAR}}-{{{year}}}-1}} | |||
}} and | |||
}} {{#expr:{{CURRENTMONTH}}-{{{month}}}+11}} or {{#expr:{{CURRENTMONTH}}-{{{month}}}+12}} months | |||
}} | |||
}} | |||
}} | |||
|{{#ifexpr:{{CURRENTYEAR}}={{{year}}} | |||
|0 years | |||
|{{#expr:{{CURRENTYEAR}}-{{{year}}}-1}} or {{AgeFull/display | |||
|years={{#expr:{{CURRENTYEAR}}-{{{year}}}}} | |||
}} | }} | ||
}} | |||
}} | }} | ||
}} | |some time | ||
}} | }}</includeonly><noinclude>Copied from Wikipedia's [[wp:Template:Age in years, months and days|Age in years, months and days]] template. The three parameters are "year", "month", and "day", all optional. Here's what happens if you supply a specific date: | ||
"Oni is <nowiki>{{AgeFull|year=2001|month=1|day=29}}</nowiki> old"<br /> | |||
yields<br /> | |||
Oni is {{AgeFull|year=2001|month=1|day=29}} old | |||
whereas "Oni is <nowiki>{{AgeFull|year=2001|month=1}}</nowiki> old"<br /> | |||
yields<br /> | |||
Oni is {{AgeFull|year=2001|month=1}} old | |||
and "Oni is <nowiki>{{AgeFull|year=2001}}</nowiki> old"<br /> | |||
yields<br /> | |||
Oni is {{AgeFull|year=2001}} old | |||
If you're content with just getting an age in whole years and you don't want the equivocating "X or Y years old", use the simpler template [[Template:Age]]. | |||
[[Category:Utility templates]]</noinclude> |
Latest revision as of 02:31, 28 June 2022
Copied from Wikipedia's Age in years, months and days template. The three parameters are "year", "month", and "day", all optional. Here's what happens if you supply a specific date:
"Oni is {{AgeFull|year=2001|month=1|day=29}} old"
yields
Oni is 23 years and 10 months old
whereas "Oni is {{AgeFull|year=2001|month=1}} old"
yields
Oni is 23 years and 9 or 10 months old
and "Oni is {{AgeFull|year=2001}} old"
yields
Oni is 22 or 23 years old
If you're content with just getting an age in whole years and you don't want the equivocating "X or Y years old", use the simpler template Template:Age.