Template:Date table sorting/doc
![]() | 自2011年10月16日起,本条目已经超过90天没有翻译。 |
此模板目前正依照其他维基百科上的内容进行翻译。 (2011年10月16日) |
![]() | 此頁面是Template:Date table sorting的Template文档。 此頁面可能包含了模板的使用說明、分類和其他内容。 |
DTS代表Date Table Sorting(以日期排序),用於在能排序表格裡整理和顯示日期(幫助:排序(英文))。
它解決的問題
通常如果要排序的話,日期必須要使用YYYY-MM-DD的格式輸入。但是,這格式與格式手冊中指定的格式不同。這模板會自動製作用作排序的<span style="display:none">1776-07-04</span>
,但會以July 4, 1776的形式顯示。如果想要使輸出隱藏,請使用{{dtsh}} 模板。
參數
![]() | 可以使用兩個有名字的參數來修改日期顯示格式。
|
{{dts|年|月|日|公元前}} | {{dts|日}} |
---|---|
所以,例如公元前5年,可以使用 "5|bc" or "-4"。 A time period (year or month and year) is sorted according to its start, and time periods with the same starting moment are in order of descending length: a year comes before its first month; a month comes before its first day. |
|
输入
{{dts|year|month|day|BC}}
- {{
dts|1776|July|4
}}
{{dts|date}}
- {{
dts|1776-07-04
}} - {{
dts|July 4, 1776
}} - {{
dts|4 July 1776
}}
当处理单一的日期参数时,除非只有一个数字(那么它将被解释为年份),模板将根据php date/time format来解释参数。默认就是按照输入的参数来显示的。If the first parameter is not just the year, but no format parameter is supplied, due to a call of function #time
the maximum number of calls of this template on a page is 1200.
Using format=mdy, format=dmy, or format=auto produces a format that depends on, but is not necessarily equal to the format of the supplied date. This requires multiple calls of function #time
, reducing the maximum number of calls of this template on a page in the worst case to 88, see below.
Also see the examples below.
Output
Output sent to table
<span style="display:none">01776-07-04</span> July 4, 1776
or<span style="display:none">01776-07-04</span> 4 July 1776
Output displayed to user
- July 4, 1776 or
- 4 July 1776
链接
本模板默认自动链接到日期。若要关闭链接,则可使用参数link=off
。根据目前的指引,此模板不再支持日期的内部链接。请不要使用此参数,并请将此参数从目前的模板调用中移除。
Examples
Normal function of the template. | The template with debug=yes , which causes hidden parts to appear:
|
---|---|
Limitation
Template:Dts/formauto calls #time
with format strings with a total length of up to 68 characters.
The worst case is when the default case of the #switch
applies, e.g. for the format 1876-08-25. In that case the template can only be called 88 times (here less because of the other examples):
Lua错误:expandTemplate: template "dts/formauto" does not exist。
Error handling
During early 2009, Template:Dts generated month names for invalid month numbers, such as number 23 displaying "November". No warning is displayed, for the formatted page, that such invalid dates are being used on the page.
See also
- {{dtsh}}, hides the template's output
- {{TBA}}, allows quarters, and allows sorting of time periods by end date.
- Template:dts(討論 - 鏈入頁面 - 编辑), since on Meta e.g. 09999 9999 induces numeric sort mode, "&" is prefixed to force string sort mode.
- {{dts1}}
- {{dts vgr}}, for video game release dates.
- {{sort}}, sorting by a specified key
- {{sortname}}, full name sorting.
- {{tts}}, for sorting times in result tables of athletic events (only needed in certain cases - see template documentation)