Open main menu

Changes

Template:Age in days/doc

4,533 bytes added, 17:58, 15 December 2018
m
no edit summary
{{Documentation subpage}}
<!-- Place categories where indicated at the bottom of this page and interwikis at Wikidata -->
{{High-use|2348}}
{{Lua|Module:Age}}
{{Template shortcuts|aid}}

This template returns the number of days between two dates. Dates may be input either as full dates or as year, month and day. Omitted parameters to their current value.

==Usage==
====Full dates====
To use, type:
:{|
|-
|<code><nowiki>{{age in days|date1|date2}}</nowiki></code>&nbsp;||(number of days between dates 1 and 2),
|-
|<code><nowiki>{{age in days|date1}}</nowiki></code> ||(number of days since date 1) or
|-
|<code><nowiki>{{age in days||date2}}</nowiki></code> ||(number of days until date 2)
|}

Examples:
:{|
|-
|<code><nowiki>{{age in days|19 Aug 2008|4 Sep 2010}}</nowiki></code> ||gives {{age in days|19 Aug 2008|4 Sep 2010}}
|-
|<code><nowiki>{{age in days|27 May 2002}}</nowiki></code> ||gives {{age in days|27 May 2002}}
|-
|<code><nowiki>{{age in days||{{#time:j M Y|+ 15 months}}}}</nowiki></code>&nbsp;||gives {{age in days||{{#time:j M Y|+ 15 months}}}}
|}

====Year, month and day====
To use, type:
:{|
|-
|<code><nowiki>{{age in days|year1|month1|day1|year2|month2|day2}}</nowiki></code>&nbsp;||(number of days between dates 1 and 2),
|-
|<code><nowiki>{{age in days|year1|month1|day1}}</nowiki></code> ||(number of days since date 1) or
|-
|<code><nowiki>{{age in days||||year2|month2|day2}}</nowiki></code> ||(number of day until date 2)
|}

Or with named parameters:
:{|
|-
|<code><nowiki>{{age in days|month1= |day1= |year1= |month2= |day2= | year2= }}</nowiki></code>&nbsp;||(number of days between dates 1 and 2),
|-
|<code><nowiki>{{age in days|month1= |day1= |year1= }}</nowiki></code> ||(number of days since date 1) or
|-
|<code><nowiki>{{age in days|month2= |day2= | year2= }}</nowiki></code> ||(number of day until date 2)
|}

Examples:
{|
|-
|<code><nowiki>{{age in days|2007|5|24|2008|4|23}}</nowiki></code>&nbsp;||gives {{age in days|2007|5|24|2008|4|23}}
|-
|<code><nowiki>{{age in days|2007|5|24}}</nowiki></code> ||gives {{age in days|2007|5|24}}
|}

===Sorting===
By adding {{para|sortable|on}} a sort key will be added to the output for use in sortable tables. The sort key is produced by {{tl|nts}} and is based on the SI unit of time (the second).

===Formatting===
Three styles of formatting are possible.
:{|
|-
|{{para|format|raw}} ||gives unformatted numbers with hyphens as minus signs<ref>Negative days will occur if the first date is after the second.</ref> (for use in further calculations).
|-
|{{para|format|commas}}&nbsp;||gives numbers formatted with commas (using <code><nowiki>{{formatnum:}}</nowiki></code>) and true minus signs.
|-
|{{para|format|gaps}} ||gives numbers formatted with thin spaces (using {{tl|val}}) and true minus signs.
|}

For reasons of retrospective compatibility, the default when inputting dates as year, month and day is {{para|format|raw}}; however when inputting dates in full it is {{para|format|commas}}.

:Note
{{Reflist}}

===Showing the unit===
The default is not to show units. To show the unit ("day", days" or "d") use {{para|show unit}}.

:{|
|-
|{{para|show unit|abbr}}&nbsp;||adds "d" after the number of days.
|-
|{{para|show unit|full}} ||adds "day" or "days" after the number of days as appropriate.
|}

===Rounding===
The template rounds down to the nearest number of full days.

===Time zones===
As noted above, date parameters left undefined default to their current value. Note that this is the current UTC value. Instead of leaving the parameter blank, however, an offset may be added, {{nowrap|for example, <code><nowiki>{{age in days|28 December 2007|+ 5 hours 45 min}}</nowiki></code>}} will give the number of days since the [[king of Nepal]] was deposed.{{dubious}} Note that this will only work when entering full dates {{nowrap|(e.g. <code><nowiki>{{age in days|2007|12|28|+ 5 hours 45 min}}</nowiki></code>}} will produce an error message).

==See also==
{{Commons|Template:Age in days}}
* [[Wikipedia:Age calculation templates]]
* {{tl|Duration in days}}
* {{tl|Time ago}}

{{Birth, death and age templates|age}}

<includeonly>{{sandbox other||
<!-- Categories below this line and interwikis at Wikidata -->
[[Category:Date mathematics templates|{{PAGENAME}}]]
[[Category:Date-computing templates|{{PAGENAME}}]]

}}</includeonly>
Anonymous user