Difference between revisions of "Template:Age in months"

From blackwiki
Jump to navigation Jump to search
blackwiki>Waldyrious
(whitespace for code readability + make consistent to documentation (added named parameters))
blackwiki>Johnuniq
(use Module:Age for features including ability to enter dates in full and to detect invalid dates)
Line 1: Line 1:
<includeonly>{{#expr:
+
<includeonly>{{#invoke:age|age_generic|template=age_m}}</includeonly><noinclude>{{documentation}}</noinclude>
  12 * (
 
    {{{year2 | {{{4 | {{CURRENTYEAR}} }}} }}} -
 
    {{{year1 | {{{1 | {{CURRENTYEAR}} }}} }}}
 
  ) + (
 
    {{{month2 | {{{5 | {{CURRENTMONTH}} }}} }}} -
 
    {{{month1 | {{{2 | {{CURRENTMONTH}} }}} }}}
 
  ) +
 
  {{#ifexpr: {{{day2 | {{{6 | {{CURRENTDAY}} }}} }}} >= {{{day1 | {{{3 | {{CURRENTDAY}} }}} }}}
 
    | 0
 
    | -1
 
  }}
 
}}</includeonly><noinclude>
 
 
 
The content of this template is only visible when the template is transcluded.
 
 
 
{{documentation}}
 
<!-- Add categories and interwikis to the /doc subpage, not here! -->
 
</noinclude>
 

Revision as of 03:58, 3 April 2018

Template documentation[view] [edit] [history] [purge]

This template returns the number of full months between two dates, or between a specified date and today (UTC).

Usage

{{age in months|year1|month1|day1|year2|month2|day2}}
{{age in months|year1|month1|day1}}
{{age in months|date1}}
{{age in months|date1|date2}}

Examples

  • {{age in months|1970|7|23|2003|7|14}} → 395
  • {{age in months|1989|7|23}} → 433
  • {{age in months|23 July 1989}} → 433
  • {{age in months|6 August 2025|5 September 2025}} → 0

If you use this template for calculating someone's age in months at death or age in months at a certain date (rather than their current age in months), please substitute it into the page, for example: {{subst:age in months|1989|7|23|2003|7|14}}.