Template:Age in days: Difference between revisions
Appearance
Content deleted Content added
use Module:Age for greater consistency between age templates and ability to detect invalid dates |
Undid revision 838133625 by Johnuniq (talk) – switch to module broke Template:Uspop use case; caused parser function errors |
||
Line 1: | Line 1: | ||
<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 |
|||
<includeonly>{{#invoke:age|age_generic|template=age_days}}</includeonly><noinclude>{{documentation}}</noinclude> |
|||
|{{Age in days/day |
|||
|f={{{format|}}} |
|||
|s={{{sortable|}}} |
|||
|u={{{show unit|}}} |
|||
|{{#expr: |
|||
+ {{Gregorian serial date |
|||
|day = {{{day2|{{{6|{{CURRENTDAY}}}}}}}} |
|||
|month = {{{month2|{{{5|{{CURRENTMONTH}}}}}}}} |
|||
|year = {{{year2|{{{4|{{CURRENTYEAR}}}}}}}} |
|||
}} |
|||
- {{Gregorian serial date |
|||
|day = {{{day1|{{{3|{{CURRENTDAY}}}}}}}} |
|||
|month = {{{month1|{{{2|{{CURRENTMONTH}}}}}}}} |
|||
|year = {{{year1|{{{1|{{CURRENTYEAR}}}}}}}} |
|||
}} |
|||
}}<!-- |
|||
-->}} |
|||
|{{Age in days/sec |
|||
|f={{{format|}}} |
|||
|s={{{sortable|}}} |
|||
|u={{{show unit|}}} |
|||
|{{#expr:{{#time:U|{{{2|}}}}}-{{#time:U|{{{1|}}}}}}}<!-- |
|||
-->}} |
|||
}}</includeonly><noinclude> |
|||
{{documentation}} |
|||
</noinclude> |
Revision as of 20:03, 25 April 2018
![]() | This template is used on approximately 4,800 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
![]() | This template uses Lua: |
This template returns the number of days between two dates. Dates may be input either as full dates or as year, month and day.
Usage
Full dates
To use, type:
{{age in days|date1|date2}}
(number of days between dates 1 and 2), {{age in days|date1}}
(number of days since date 1) or {{age in days||date2}}
(number of days until date 2)
Examples:
{{age in days|19 Aug 2008|4 Sep 2010}}
gives Template:Age in days/sec {{age in days|27 May 2002}}
gives Template:Age in days/sec {{age in days||{{#time:j M Y|+ 15 months}}}}
gives Template:Age in days/sec
Year, month and day
To use, type:
{{age in days|year1|month1|day1|year2|month2|day2}}
(number of days between dates 1 and 2), {{age in days|year1|month1|day1}}
(number of days since date 1) or {{age in days||||year2|month2|day2}}
(number of day until date 2)
Or with named parameters:
{{age in days|month1= |day1= |year1= |month2= |day2= | year2= }}
(number of days between dates 1 and 2), {{age in days|month1= |day1= |year1= }}
(number of days since date 1) or {{age in days|month2= |day2= | year2= }}
(number of day until date 2)
Examples:
{{age in days|2007|5|24|2008|4|23}} |
gives Template:Age in days/day |
{{age in days|2007|5|24}} |
gives Template:Age in days/day |
Sorting
By adding |sortable=on
a sort key will be added to the output for use in sortable tables.
Formatting
Three styles of formatting are possible.
|format=raw
gives unformatted numbers with hyphens as minus signs[1] (for use in further calculations). |format=commas
gives numbers formatted with commas and true minus signs.
For reasons of retrospective compatibility, the default when inputting dates as year, month and day is |format=raw
; however when inputting dates in full it is |format=commas
.
- Note
- ^ Negative days will occur if the first date is after the second.
Showing the unit
The default is not to show units. To show the unit ("day", days" or "d") use |show unit=
.
|show unit=abbr
adds "d" after the number of days. |show unit=full
adds "day" or "days" after the number of days as appropriate.