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来解释参数。默认就是按照输入的参数来显示的。若果第一個参数不是只是年份,但又沒有提供格式参数,由於有一個函數#time
的召喚,一個頁面中使用本模板的最多召喚次數是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.
另外請參見下方的例子。
输出
發送到表格的輸出
<span style="display:none">01776-07-04</span> July 4, 1776
或<span style="display:none">01776-07-04</span> 4 July 1776
顯示給用戶的輸出
- July 4, 1776 或
- 4 July 1776
链接
本模板默认自动链接到日期。若要关闭链接,则可使用参数link=off
。根据目前的指引,此模板不再支持日期的内部链接。请不要使用此参数,并请将此参数从目前的模板调用中移除。
例子
Normal function of the template. | The template with debug=yes , which causes hidden parts to appear:
|
---|---|
註解
排序非完整日期
完整年份或月份
完整年份或月份(或完整年月),例如{{dts|2020}}
、{{dts|Jan}}
和{{dts|2020|1}}
,系統會按其第一個日子排序。
沒有年份
如果未指定年份,系統將會視年份為現時年份來進行排序。
處理錯誤
輸入無效的日期格式(通常)會產生一條錯誤消息,例如以下內容。
Module:Date table sorting錯誤:6月只有30天,沒有「第35天」!
曆法選擇
本模板無法區分儒略曆和公曆日期。另外,它不能從一個曆法輸入日期並按另一曆法輸出日期。所以,要確保排序良好,用家必須把日期統一於一個曆法,或者確定一個轉折日(例如,確定1582年10月4日為儒略曆,以後的所有日期為公曆),這可以用一條條的方法實現。如果可能造成混淆,用家有責任解釋給讀者究竟顯示的日期是儒略曆還是公曆。
參見
- {{sort}},以一個特定的鑰匙排序
- {{sortname}},排序人名(用姓氏和名稱作為預設排序鑰匙)。
- {{tts}},用於在體育賽事結果表中排序時間(只需要用於一定情況——參見該模板的文档页面)
- {{number table sorting}},為數字而設