Difference between revisions of "Template:Age"
From eRepublik Official Wiki
m (Andycro moved page User:Bogi/Age in years, months and days to Template:Age without leaving a redirect: implementing) |
(usage added) |
||
Line 1: | Line 1: | ||
− | {{#if:{{#ifeq:{{{6|¤}}}|¤||1}}{{#ifeq:{{{5|¤}}}|¤||1}}{{#ifeq:{{{4|¤}}}|¤||1}} | + | <noinclude> |
+ | Age template is used to calculate the time between two dates. If no date, or incomplete date, is selected an error message shows ''error with the input''. | ||
+ | |||
+ | To properly calculate date please use the following formula: | ||
+ | <pre>{{Age|Older Year|Older Month|Older Day|Newer Year|Newer Month|Newer Day}}</pre> | ||
+ | |||
+ | If only one date is selected it calculates time from today to til date. | ||
+ | <pre>{{Age|Year|Month|Day}}</pre> | ||
+ | |||
+ | '''Please do not use names for months, use numbers.''' | ||
+ | ==Examples== | ||
+ | <pre>{{Age|1989|7|23}} → 30 years, 9 months and 7 days | ||
+ | {{Age|1989|7|23|2003|7|24}} → 14 years and 1 day | ||
+ | {{Age|2007|03|02|2008|03|02}} → 1 year</pre></noinclude><includeonly>{{#if:{{#ifeq:{{{6|¤}}}|¤||1}}{{#ifeq:{{{5|¤}}}|¤||1}}{{#ifeq:{{{4|¤}}}|¤||1}} | ||
|{{#iferror:{{#time:Y-m-d|{{{6}}}-{{{5}}}-{{{4}}}}} | |{{#iferror:{{#time:Y-m-d|{{{6}}}-{{{5}}}-{{{4}}}}} | ||
|{{error|Error: Invalid time. }} | |{{error|Error: Invalid time. }} | ||
Line 5: | Line 18: | ||
|{{#if:{{{2|{{{month|}}}}}} | |{{#if:{{{2|{{{month|}}}}}} | ||
|{{#if:{{{3|{{{day|}}}}}} | |{{#if:{{{3|{{{day|}}}}}} | ||
− | |{{ | + | |{{Age/display |
|years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-{{#ifexpr:{{{5|{{CURRENTMONTH}}}}}>{{{2|{{{month}}}}}} | |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-{{#ifexpr:{{{5|{{CURRENTMONTH}}}}}>{{{2|{{{month}}}}}} | ||
|0 | |0 | ||
Line 66: | Line 79: | ||
|{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{{1|{{{year}}}}}} | |{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{{1|{{{year}}}}}} | ||
|0 years | |0 years | ||
− | |{{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-1}} or {{ | + | |{{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-1}} or {{Age/display |
|years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}}} | |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}}} | ||
}} | }} | ||
Line 73: | Line 86: | ||
|{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{{1|{{{year}}}}}} | |{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{{1|{{{year}}}}}} | ||
|<!--null value--> | |<!--null value--> | ||
− | |{{ | + | |{{Age/display |
|years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}}} | |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}}} | ||
}} and | }} and | ||
− | }} {{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}-1}} or {{ | + | }} {{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}-1}} or {{Age/display |
|months={{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}}} | |months={{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}}} | ||
}} | }} | ||
|{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{#expr:{{{1|{{{year}}}}}}+1}} | |{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{#expr:{{{1|{{{year}}}}}}+1}} | ||
|<!--null value--> | |<!--null value--> | ||
− | |{{ | + | |{{Age/display |
|years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-1}} | |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-1}} | ||
}} and | }} and | ||
− | }} {{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}+11}} or {{ | + | }} {{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}+11}} or {{Age/display |
|months={{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}+12}}}} | |months={{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}+12}}}} | ||
}} | }} | ||
Line 91: | Line 104: | ||
|{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{{1|{{{year}}}}}} | |{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{{1|{{{year}}}}}} | ||
|0 years | |0 years | ||
− | |{{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-1}} or {{ | + | |{{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-1}} or {{Age/display |
|years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}}} | |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}}} | ||
}} | }} | ||
}} | }} | ||
}} | }} | ||
− | | | + | |error with the input |
− | }} | + | }}</includeonly> |
Revision as of 06:55, 30 April 2020
Age template is used to calculate the time between two dates. If no date, or incomplete date, is selected an error message shows error with the input.
To properly calculate date please use the following formula:
{{Age|Older Year|Older Month|Older Day|Newer Year|Newer Month|Newer Day}}
If only one date is selected it calculates time from today to til date.
{{Age|Year|Month|Day}}
Please do not use names for months, use numbers.
Examples
{{Age|1989|7|23}} → 30 years, 9 months and 7 days {{Age|1989|7|23|2003|7|24}} → 14 years and 1 day {{Age|2007|03|02|2008|03|02}} → 1 year