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

Template:Date table sorting/sandbox

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

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年以下)
例子
輸入風格 輸入碼 隱藏排序键 顯示的輸出

Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row

格式化

[编辑]

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

例子
Template:Date table sorting/sandbox/rowTemplate:Date table sorting/sandbox/rowTemplate:Date table sorting/sandbox/rowTemplate:Date table sorting/sandbox/row
輸出格式 輸入碼 隱藏排序键 顯示的輸出

Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row

Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row

Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row

Template:Date table sorting/sandbox/row

Template:Date table sorting/sandbox/row

Template:Date table sorting/sandbox/row

Template:Date table sorting/sandbox/row

Template:Date table sorting/sandbox/row

注意:以下格式的值皆視為無效

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

縮寫

[编辑]

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

例子
縮寫方法 輸入碼 隱藏排序键 顯示的輸出

Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row

額外排序键

[编辑]

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

例子
輸入碼 隱藏排序键 顯示的輸出

Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row Template:Date table sorting/sandbox/row

文字換行

[编辑]

要關閉自動換行的話,請使用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/sandbox
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?