Difference between revisions of "Template:Age"

From eRepublik Official Wiki
Jump to: navigation, search
(usage added)
(usage improved)
Line 1: Line 1:
 
<noinclude>
 
<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''.
+
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.
  
 
To properly calculate date please use the following formula:
 
To properly calculate date please use the following formula:
 
<pre>{{Age|Older Year|Older Month|Older Day|Newer Year|Newer Month|Newer Day}}</pre>
 
<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.  
+
If only one date is selected it calculates time from today to that date.  
 
<pre>{{Age|Year|Month|Day}}</pre>
 
<pre>{{Age|Year|Month|Day}}</pre>
 +
Or you can use day=| month=| year=| in any order you want:
 +
<pre>{{Age|month=number of the month|day=number of the day|year=number of the year}}</pre>
  
 
'''Please do not use names for months, use numbers.'''
 
'''Please do not use names for months, use numbers.'''
 +
 
==Examples==
 
==Examples==
<pre>{{Age|1989|7|23}} → 30 years, 9 months and 7 days
+
<pre>{{Age|1989|7|23}}</pre> {{Age|1989|7|23}}
{{Age|1989|7|23|2003|7|24}} → 14 years and 1 day
+
<pre>{{Age|1989|7|23|2003|7|24}}</pre> {{Age|1989|7|23|2003|7|24}}
{{Age|2007|03|02|2008|03|02}} → 1 year</pre></noinclude><includeonly>{{#if:{{#ifeq:{{{6|¤}}}|¤||1}}{{#ifeq:{{{5|¤}}}|¤||1}}{{#ifeq:{{{4|¤}}}|¤||1}}
+
<pre>{{Age|2007|03|02|2008|03|02}}</pre> {{Age|2007|03|02|2008|03|02}}
 +
<pre>{{Age|month=01|day=23|year=1989}}</pre> → {{Age|month=01|day=23|year=1989}}
 +
<pre>{{Age|year=1989}}</pre> → {{Age|year=1989}}[[Category:Templates]]</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 38: Line 43:
 
       |0
 
       |0
 
       }}
 
       }}
     }}{{#ifexpr:{{User:Bogi/Gregorian serial date
+
     }}{{#ifexpr:{{Gregorian serial date
 
       |year={{{4|{{CURRENTYEAR}}}}}
 
       |year={{{4|{{CURRENTYEAR}}}}}
 
       |month={{{5|{{CURRENTMONTH}}}}}
 
       |month={{{5|{{CURRENTMONTH}}}}}
       |day={{{6|{{CURRENTDAY}}}}}}}-{{User:Bogi/Gregorian serial date
+
       |day={{{6|{{CURRENTDAY}}}}}}}-{{Gregorian serial date
 
       |year={{{4|{{CURRENTYEAR}}}}}
 
       |year={{{4|{{CURRENTYEAR}}}}}
 
       |month={{#expr:{{{5|{{CURRENTMONTH}}}}}-1}}
 
       |month={{#expr:{{{5|{{CURRENTMONTH}}}}}-1}}
Line 50: Line 55:
 
     }}}}
 
     }}}}
 
     |days={{#ifexpr:{{{6|{{CURRENTDAY}}}}}<{{{3|{{{day}}}}}}
 
     |days={{#ifexpr:{{{6|{{CURRENTDAY}}}}}<{{{3|{{{day}}}}}}
     |{{#expr:{{User:Bogi/Gregorian serial date
+
     |{{#expr:{{Gregorian serial date
 
       |year={{{4|{{CURRENTYEAR}}}}}
 
       |year={{{4|{{CURRENTYEAR}}}}}
 
       |month={{{5|{{CURRENTMONTH}}}}}
 
       |month={{{5|{{CURRENTMONTH}}}}}
       |day={{{6|{{CURRENTDAY}}}}}}}-{{User:Bogi/Gregorian serial date
+
       |day={{{6|{{CURRENTDAY}}}}}}}-{{Gregorian serial date
 
       |year={{{4|{{CURRENTYEAR}}}}}
 
       |year={{{4|{{CURRENTYEAR}}}}}
       |month={{#expr:{{{5|{{CURRENTMONTH}}}}}-{{#ifexpr:{{User:Bogi/Gregorian serial date
+
       |month={{#expr:{{{5|{{CURRENTMONTH}}}}}-{{#ifexpr:{{Gregorian serial date
 
         |year={{{4|{{CURRENTYEAR}}}}}
 
         |year={{{4|{{CURRENTYEAR}}}}}
 
         |month={{{5|{{CURRENTMONTH}}}}}
 
         |month={{{5|{{CURRENTMONTH}}}}}
         |day={{{6|{{CURRENTDAY}}}}}}}-{{User:Bogi/Gregorian serial date
+
         |day={{{6|{{CURRENTDAY}}}}}}}-{{Gregorian serial date
 
         |year={{{4|{{CURRENTYEAR}}}}}
 
         |year={{{4|{{CURRENTYEAR}}}}}
 
         |month={{#expr:{{{5|{{CURRENTMONTH}}}}}-1}}
 
         |month={{#expr:{{{5|{{CURRENTMONTH}}}}}-1}}

Revision as of 07:25, 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 will show up.

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 10 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 10 days
{{Age|year=1989}}
→ 34 or 35 years