模板:Age in days/sandbox
![]() | 这是Template:Age in days(差异)的沙盒。 参见本模板的测试样例。 |
![]() | 此模板沙盒被引用于许多页面。 为了避免造成大规模的影响,所有对此模板沙盒的编辑应先于沙盒、测试样例或您的沙盒上测试。 测试后无误的版本可以一次性地加入此模板沙盒中,但是修改前请务必于讨论页发起讨论。 模板引用数量会自动更新。 |
Usage
编辑Inputting dates
编辑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.
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 746 {{age in days|27 May 2002}}
gives 8,120 {{age in days||{{#time:Y-m-d|+ 15 months}}}}
gives 457
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 335 |
{{age in days|2007|5|24}} |
gives 6297 |
Sorting
编辑By adding |sortable=on
a sort key will be added to the output for use in sortable tables. The sort key is produced by {{nts}} and is based on the SI unit of time (the second).
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 (using {{formatnum:}}
) and true minus signs.|format=gaps
gives numbers formatted with thin spaces (using {{val}}) 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.
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, for example, {{age in days|28 December 2007|+ 5 hours 45 min}}
will give the number of days since the king of Nepal was deposed. Note that this will only work when entering full dates (e.g. {{age in days|2007|12|28|+ 5 hours 45 min}}
will produce an error message).
See also
编辑![](http://upload.wikimedia.org/wikipedia/commons/thumb/4/4a/Commons-logo.svg/30px-Commons-logo.svg.png)
|
上述文档嵌入自Template:Age in days/doc。 (编辑 | 历史) 编者可以在本模板的沙盒 (编辑 | 差异)和测试样例 (编辑)页面进行实验。 请在/doc子页面中添加分类。本模板的子页面。 |