For faster navigation, this Iframe is preloading the Wikiwand page for Template:Date table sorting.

Template:Date table sorting

文档图示 模板文档[查看] [编辑] [历史] [清除缓存]

DTS代表Date Table Sorting(以日期排序),用於在能排序表格裡整理和顯示日期(幫助:排序(英文))。

它解決的問題

通常如果要排序的話,日期必須要使用YYYY-MM-DD的格式輸入。但是,這格式與格式手冊中指定的格式不同。這模板會自動製作用作排序的排序键,但會以另外的形式顯示輸出(例如年-月-日)。

參數

日期

年月日不一定要分開輸入。
((dts||||時代)) ((dts|日期))
  • 第一個參數 – 年份(如月份不空缺就非必要)
    • 正數(1 到 9999)代表公元前或公元後年份(視乎第四个参数),第四个参数空缺的話,默認代表公元後年份。
    • 負數(−1 到 −9999)代表公元前年份(第四个参数必須空缺)。
  • 第二个参数 – 月份(如日子空缺就非必要)
    • 月份的全称 – February 或 february
    • 月份的缩写– Feb 或 feb
    • 月份的数字 – 2 或者 02
  • 第三个参数 – 日子(非必要)
    • 日期数字 – 7 或 07
  • 第四个参数 – (非必要)
    • 可以是 BC、AD、BCE 或 CE
    • 当年份值为正时使用
  • 第一个参数 – 完整日期。国际格式、美国格式[需要解释]或 YYYY-MM-DD 格式
    • 国际格式的日期不会被改变。YYYY-MM-DD 式日期默认会转换到US格式。
    • 可以接受月份缩写
    • 大小写和逗号错误将被改正
    • 模板使用((#time:)),所以它也受解析器函数的限制(例如不支持公元100年以下)
例子
輸入風格 輸入碼 隱藏排序键 顯示的輸出
((Date_table_sorting|)) ((Date_table_sorting|1893)) 000000001893-01-01-0000 1893年
((Date_table_sorting|-89)) -999999999911-01-01-0000 公元前89年
((Date_table_sorting|)) ((Date_table_sorting|Oct)) 000000002024-10-01-0000 10月
((Date_table_sorting|月 年)) ((Date_table_sorting|February 1767)) 000000001767-02-01-0000 1767年2月
((Date_table_sorting|日 月 年)) ((Date_table_sorting|12 Aug 1987)) 000000001987-08-12-0000 1987年8月12日
((Date_table_sorting|月 日, 年)) ((Date_table_sorting|July 1, 1867)) 000000001867-07-01-0000 1867年7月1日
((Date_table_sorting|日 月)) ((Date_table_sorting|25 October)) 000000002024-10-25-0000 2024年10月25日
((Date_table_sorting|月 日)) ((Date_table_sorting|Jan 1)) 000000002024-01-01-0000 2024年1月1日
((Date_table_sorting|YYYY-MM-DD)) ((Date_table_sorting|2014-12-09)) 000000002014-12-09-0000 2014年12月9日
((Date_table_sorting||)) ((Date_table_sorting|1990|10)) 000000001990-10-01-0000 1990年10月
((Date_table_sorting|1980|Dec)) 000000001980-12-01-0000 1980年12月
((Date_table_sorting|1970|August)) 000000001970-08-01-0000 1970年8月
((Date_table_sorting|||)) ((Date_table_sorting|2024|Jun|12)) 000000002024-06-12-0000 2024年6月12日
((Date_table_sorting|-204|11|22)) -999999999796-11-22-0000 公元前204年11月22日
((Date_table_sorting||||時代)) ((Date_table_sorting|44|3|15|BC)) -999999999956-03-15-0000 公元前44年3月15日
((Date_table_sorting|94|Oct|17|AD)) 000000000094-10-17-0000 94年10月17日
((Date_table_sorting||)) ((Date_table_sorting||May)) 000000002024-05-01-0000 5月
((Date_table_sorting|||)) ((Date_table_sorting||Sep|12)) 000000002024-09-12-0000 9月12日

格式化

使用format可以做出一個依賴但不需要相同於提供日期的格式。這需要多次調用函數 ((#time:)),減少一個頁面中使用本模板的最多召喚次數到最差88次,參見下方。format 參數可以用九個數值。

例子
輸出格式 輸入碼 隱藏排序键 顯示的輸出
年-月-日 ((Date_table_sorting|26 Jan 1788)) 000000001788-01-26-0000 1788年1月26日
((Date_table_sorting|March 12, 1557)) 000000001557-03-12-0000 1557年3月12日
((Date_table_sorting|1975-02-13)) 000000001975-02-13-0000 1975年2月13日


ymd 年-月-日(預設) ((Date_table_sorting|August 31, 1901|format=ymd)) 000000001901-08-31-0000 1901年8月31日
((Date_table_sorting|2006-11-08|format=ymd)) 000000002006-11-08-0000 2006年11月8日
((Date_table_sorting|1888|5|8|format=ymd)) 000000001888-05-08-0000 1888年5月8日
((Date_table_sorting|-56|08|09|format=ymd)) -999999999944-08-09-0000 公元前56年8月9日


md 月-日 ((Date_table_sorting|26 Jun 1988|format=md)) 000000001988-06-26-0000 6月26日
((Date_table_sorting|2002-05-27|format=md)) 000000002002-05-27-0000 5月27日
dm 月-日 ((Date_table_sorting|Feb 26, 1788|format=dm)) 000000001788-02-26-0000 2月26日
((Date_table_sorting|2020-10-15|format=dm)) 000000002020-10-15-0000 10月15日


my 年-月 ((Date_table_sorting|16 November 1488|format=my)) 000000001488-11-16-0000 1488年11月


d ((Date_table_sorting|6 July 1666|format=d)) 000000001666-07-06-0000 6日


m 月份 ((Date_table_sorting|1980-02-12|format=m)) 000000001980-02-12-0000 2月


y 年份 ((Date_table_sorting|-26|Jan|18|format=y)) -999999999974-01-18-0000 公元前26年


hide 隱藏日期 ((Date_table_sorting|15 October 1800|format=hide)) 000000001800-10-15-0000
注意:以下格式的值皆視為無效
dmy 中文版視為無效 ((Date_table_sorting|Sep 13, 1888|format=dmy)) 000000001888-09-13-0000 1888年9月13日
((Date_table_sorting|1983-01-03|format=dmy)) 000000001983-01-03-0000 1983年1月3日


mdy 中文版視為無效 ((Date_table_sorting|August 31, 1901|format=mdy)) 000000001901-08-31-0000 1901年8月31日
((Date_table_sorting|2006-11-08|format=mdy)) 000000002006-11-08-0000 2006年11月8日

当处理单一的日期参数时,除非只有一个数字(那么它将被解释为年份),模板将根据php date/time format来解释参数。但由於中文習慣的格式的影響,預設皆是使用年-月-日由於本模板調用函數((#time:)),因此單一頁面中最多僅能使用本模板1200次。[需要解释]

縮寫

在中文版本,只有一個方法縮寫日期:使用 abbr=on 參數。

例子
縮寫方法 輸入碼 隱藏排序键 顯示的輸出
((Date_table_sorting|2000-01-01)) 000000002000-01-01-0000 2000年1月1日
((Date_table_sorting|2000|1|1)) 000000002000-01-01-0000 2000年1月1日
((Date_table_sorting|1 January 2000)) 000000002000-01-01-0000 2000年1月1日
((Date_table_sorting|2000|January|1)) 000000002000-01-01-0000 2000年1月1日
輸入月份縮寫 ((Date_table_sorting|1 Jan 2000)) 000000002000-01-01-0000 2000年1月1日
((Date_table_sorting|2000|Jan|1)) 000000002000-01-01-0000 2000年1月1日
abbr=on ((Date_table_sorting|1 January 2000|abbr=on)) 000000002000-01-01-0000 2000/1/1
((Date_table_sorting|2000|January|1|abbr=on)) 000000002000-01-01-0000 2000/1/1
((Date_table_sorting|2000-01-01|abbr=on)) 000000002000-01-01-0000 2000/1/1
((Date_table_sorting|2000|1|1|abbr=on)) 000000002000-01-01-0000 2000/1/1

額外排序键

如果表格內的兩個日期一樣,它們可以利用參數 addkey 排序。

例子
輸入碼 隱藏排序键 顯示的輸出
((Date_table_sorting|2010-10-10|addkey=3)) 000000002010-10-10-0003 2010年10月10日
((Date_table_sorting|2010-10-09)) 000000002010-10-09-0000 2010年10月9日
((Date_table_sorting|2010-10-10|addkey=1)) 000000002010-10-10-0001 2010年10月10日
((Date_table_sorting|2010-10-10)) 000000002010-10-10-0000 2010年10月10日
((Date_table_sorting|2010-10-10|addkey=4)) 000000002010-10-10-0004 2010年10月10日
((Date_table_sorting|2010-10-11)) 000000002010-10-11-0000 2010年10月11日
((Date_table_sorting|2010-10-10|addkey=2)) 000000002010-10-10-0002 2010年10月10日

文字換行

要關閉自動換行的話,請使用nowrap=off參數。

註解

排序非完整日期

完整年份或月份

完整年份或月份(或完整年月),例如((dts|2020))((dts|Jan))((dts|2020|1)),系統會按其第一個日子排序。

沒有年份

如果未指定年份,系統將會視年份為現時年份來進行排序。

處理錯誤

輸入無效的日期格式(通常)會產生一條錯誤消息,例如((dts||維基百科))會產生以下內容:

Module:Date table sorting錯誤:給出的月份「維基百科」月不合理。

曆法選擇

本模板無法區分儒略曆和公曆日期。另外,它不能從一個曆法輸入日期並按另一曆法輸出日期。所以,要確保排序良好,用戶必須把日期統一於一個曆法,或者確定一個轉折日(例如,確定1582年10月4日為儒略曆,以後的所有日期為公曆),這可以用一條條的方法實現。如果可能造成混淆,用家有責任解釋給讀者究竟顯示的日期是儒略曆還是公曆。

链接

本模板默认自动链接到日期。若要关闭链接,则可使用参数link=off。根据目前的指引,此模板不再支持日期的内部链接。请不要使用此参数,并请将此参数从目前的模板调用中移除。

參見

  • ((sort)),以一個特定的鑰匙排序
  • ((sortname)),排序人名(用姓氏和名稱作為預設排序鑰匙)。
  • ((tts)),用於在體育賽事結果表中排序時間(只需要用於一定情況——參見該模板的文档页面)
  • ((number table sorting)),為數字而設
{{bottomLinkPreText}} {{bottomLinkText}}
Template:Date table sorting
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?