Difference between revisions of "Template:Age in days"

From Rigged Wiki
Jump to navigation Jump to search
m
Tag: Reverted
Line 1: Line 1:
<includeonly>{{#expr:
<includeonly>{{#ifexpr:{{{day1|}}}{{{3|}}}{{{month1|}}}{{{year1|}}}{{{day2|}}}{{{6|}}}{{{month2|}}}{{{5|}}}{{{year2|}}}{{{4|}}}{{#iferror:{{#expr:0*{{{1|}}}=0}}}}{{#iferror:{{#expr:(0*{{{2|}}}=0)*({{{2|}}}>0)*({{{2|}}}<13)}}}}0
        + {{Gregorian serial date
  |{{Age in days/day
                      |month = {{{month2|{{CURRENTMONTH}} }}}
    |f={{{format|}}}
                      |day = {{{day2|{{CURRENTDAY}} }}}
    |s={{{sortable|}}}
                      |year = {{{year2|{{CURRENTYEAR}} }}}
    |u={{{show unit|}}}
          }}
    |{{#expr:
        - {{Gregorian serial date
      + {{Gregorian serial date
                      |month = {{{month1|{{CURRENTMONTH}} }}}
          |day   = {{{day2|{{{6|{{CURRENTDAY}}}}}}}}
                      |day = {{{day1|{{CURRENTDAY}} }}}
          |month = {{{month2|{{{5|{{CURRENTMONTH}}}}}}}}
                      |year = {{{year1|{{CURRENTYEAR}} }}}
          |year  = {{{year2|{{{4|{{CURRENTYEAR}}}}}}}}
          }} }}</includeonly><noinclude>[[Category:Date templates|{{PAGENAME}}]]
        }}
[[Category:Templates using ParserFunctions|{{PAGENAME}}]]
      - {{Gregorian serial date
</noinclude><noinclude>
          |day  = {{{day1|{{{3|{{CURRENTDAY}}}}}}}}
{{Parms|
          |month = {{{month1|{{{2|{{CURRENTMONTH}}}}}}}}
{{Parm|month1|month of start date|no (see note)|defaults to current month}}
          |year  = {{{year1|{{{1|{{CURRENTYEAR}}}}}}}}
{{Parm|day1|day of month of start date|no (see note)|defaults to today's date}}
        }}
{{Parm|year1|year of start date|no (see note)|defaults to current year}}
      }}<!--
{{Parm|month2|month of end date|no (see note)|defaults to current month}}
-->}}
{{Parm|day2|day of month of end date|no (see note)|defaults to today's date}}
  |{{Age in days/sec
{{Parm|year2|year of end date|no (see note)|defaults to current year}}
    |f={{{format|}}}
}}
    |s={{{sortable|}}}
Note:  It is pointless omitting all parameters, as the calculation will then return zero (the number of days between today and today).
    |u={{{show unit|}}}
 
    |{{#expr:{{#time:U|{{{2|}}}}}-{{#time:U|{{{1|}}}}}}}<!--
If the second set of parameters is not included it will automatically calculate the days between a given date and today. To use type: '''<nowiki>{{Age in days|month1= |day1= |year1= |month2= |day2= | year2=}}</nowiki>''' <br>
-->}}
The end date will default to the current date if the second set of parameters is not used. '''<nowiki>{{Age in days|month1= |day1= |year1= }}</nowiki>''' <br>
}}</includeonly><noinclude>
Using only the 2nd set of parameters will result in a negative number as the output. '''<nowiki>{{Age in days|month2= |day2= |year2= }}</nowiki>''' <br>
{{documentation}}
Setting the parameters to 0 may result in an error <br>
See also [[Template:Age in days addrem]] for +/- to values
== Examples ==
Zero parameters
<pre>{{Age in days}}</pre> → {{Age in days}} <br>
 
First set of parameters only (Start date January 1st, 2020)
<pre>{{Age in days|month1=1|day1=1|year1=2020}}</pre>  → {{Age in days|month1=1|day1=1|year1=2020}} <br>
 
Second set of parameters only (End date January 1st, 2020)
<pre>{{Age in days|month2=1|day2=1|year2=2020}}</pre>  → {{Age in days|month2=1|day2=1|year2=2020}} <br>
 
Both sets of parameters (January 1st, 2020 to January 1st, 2022)
<pre>{{Age in days|month1=1|day1=1|year1=2020|month2=1|day2=1|year2=2022}}</pre> {{Age in days|month1=1|day1=1|year1=2020|month2=1|day2=1|year2=2022}} <br>
 
</noinclude>
</noinclude>

Revision as of 03:20, 19 March 2025

[create] Template documentation