Difference between revisions of "Template:Age"

From eRepublik Official Wiki
Jump to: navigation, search
m
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{#if:{{#ifeq:{{{6|¤}}}|¤||1}}{{#ifeq:{{{5|¤}}}|¤||1}}{{#ifeq:{{{4|¤}}}|¤||1}}
+
<noinclude>
 +
{{Documentation}}
 +
</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 7:
 
  |{{#if:{{{2|{{{month|}}}}}}
 
  |{{#if:{{{2|{{{month|}}}}}}
 
   |{{#if:{{{3|{{{day|}}}}}}
 
   |{{#if:{{{3|{{{day|}}}}}}
   |{{User:Bogi/Age in years, months and days/display
+
   |{{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 68:
 
     |{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{{1|{{{year}}}}}}
 
     |{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{{1|{{{year}}}}}}
 
     |0&nbsp;years
 
     |0&nbsp;years
     |{{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-1}}&nbsp;or {{User:Bogi/Age in years, months and days/display
+
     |{{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-1}}&nbsp;or {{Age/display
 
       |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}}}
 
       |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}}}
 
       }}
 
       }}
Line 73: Line 75:
 
     |{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{{1|{{{year}}}}}}
 
     |{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{{1|{{{year}}}}}}
 
       |<!--null value-->
 
       |<!--null value-->
       |{{User:Bogi/Age in years, months and days/display
+
       |{{Age/display
 
       |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}}}
 
       |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}}}
 
       }} and
 
       }} and
       }} {{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}-1}}&nbsp;or {{User:Bogi/Age in years, months and days/display
+
       }} {{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}-1}}&nbsp;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-->
       |{{User:Bogi/Age in years, months and days/display
+
       |{{Age/display
 
       |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-1}}
 
       |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-1}}
 
       }} and
 
       }} and
       }} {{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}+11}}&nbsp;or {{User:Bogi/Age in years, months and days/display
+
       }} {{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}+11}}&nbsp;or {{Age/display
 
       |months={{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}+12}}}}
 
       |months={{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}+12}}}}
 
     }}
 
     }}
Line 91: Line 93:
 
   |{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{{1|{{{year}}}}}}
 
   |{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{{1|{{{year}}}}}}
 
   |0&nbsp;years
 
   |0&nbsp;years
   |{{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-1}}&nbsp;or {{User:Bogi/Age in years, months and days/display
+
   |{{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-1}}&nbsp;or {{Age/display
 
     |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}}}
 
     |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}}}
 
     }}
 
     }}
 
   }}
 
   }}
 
   }}
 
   }}
  |some time
+
  |error with the input
}}
+
}}</includeonly>

Latest revision as of 15:19, 16 July 2021

[edit] [purge]

Documentation

Age template is used to calculate the time between two dates. If no date, or incomplete date, is selected an error message will show up.

Usage

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 that date.

{{Age|Year|Month|Day}}

Or you can use day=| month=| year=| in any order you want:

{{Age|month=number of the month|day=number of the day|year=number of the year}}

Please do not use names for months, use numbers.

Examples

{{Age|1989|7|23}}
→ 34 years, 10 months and 25 days
{{Age|1989|7|23|2003|7|24}}
→ 14 years and 1 day
{{Age|2007|03|02|2008|03|02}}
→ 1 year
{{Age|month=01|day=23|year=1989}}
→ 35 years, 4 months and 25 days
{{Age|year=1989}}
→ 34 or 35 years