模板:Date table sorting/doc

来自Local Chinese Wikipedia
跳转到导航 跳转到搜索

Template:NoteTA/MediaWiki 脚本错误:没有“Message box”这个模块。 Template:Lua 页面Template:楷体/styles.css没有内容。 DTS代表Date Table Sorting(以日期排序),用于在能排序表格里整理和显示日期(帮助:排序(英文))。

简介[编辑]

通常如果要排序的话,日期必须要使用YYYY-MM-DD的格式输入。但是,这格式与格式手册中指定的格式不同。这模板会自动制作用作排序的排序键,但会以另外的形式显示输出(例如年-月-日)。

参数[编辑]

日期[编辑]

年月日不一定要分开输入。
脚本错误:没有“Tlg”这个模块。 脚本错误:没有“Tlg”这个模块。
  • 第一个参数 – 年份(如月份不空缺就非必要)
    • 正数(1 到 9999)代表公元前或公元后年份(视乎第四个参数),第四个参数空缺的话,默认代表公元后年份。
    • 负数(−1 到 −9999)代表公元前年份(第四个参数必须空缺)。
  • 第二个参数 – 月份(如日子空缺就非必要)
    • 月份的全称 – February 或 february
    • 月份的缩写– Feb 或 feb
    • 月份的数字 – 2 或者 02
  • 第三个参数 – 日子(非必要)
    • 日期数字 – 7 或 07
  • 第四个参数 – (非必要)
    • 可以是 BC、AD、BCE 或 CE
    • 当年份值为正时使用
  • 第一个参数 – 完整日期。国际格式、Template:What或 YYYY-MM-DD 格式
    • 国际格式的日期不会被改变。YYYY-MM-DD 式日期默认会转换到US格式。
    • 可以接受月份缩写
    • 大小写和逗号错误将被改正
    • 模板使用Template:Tlxm,所以它也受解析器函数的限制(例如不支持公元100年以下)
例子
输入风格 输入码 隐藏排序键 显示的输出

Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row

格式化[编辑]

使用format可以做出一个依赖但不需要相同于提供日期的格式。这需要多次调用函数 Template:Tlxm,减少一个页面中使用本模板的最多召唤次数到最差88次,参见下方。format 参数可以用九个数值。

例子
Template:Date table sorting/doc/rowTemplate:Date table sorting/doc/rowTemplate:Date table sorting/doc/rowTemplate:Date table sorting/doc/rowTemplate:Date table sorting/doc/rowTemplate:Date table sorting/doc/rowTemplate:Date table sorting/doc/row
输出格式 输入码 隐藏排序键 显示的输出

Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row

Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row

Template:Date table sorting/doc/row Template:Date table sorting/doc/row

Template:Date table sorting/doc/row

Template:Date table sorting/doc/row

Template:Date table sorting/doc/row

Template:Date table sorting/doc/row

  1. 重定向 Template:Font color以下格式虽然有效,但不符合中文习惯,请勿使用

当处理单一的日期参数时,除非只有一个数字(那么它将被解释为年份),模板将根据php date/time format来解释参数。但由于中文习惯的格式的影响,预设皆是使用年-月-日Template:What

缩写[编辑]

在中文版本,只有一个方法缩写日期:使用 abbr=on 参数。

例子
缩写方法 输入码 隐藏排序键 显示的输出

Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row

额外排序键[编辑]

如果表格内的两个日期一样,它们可以利用参数 addkey 排序。

例子
输入码 隐藏排序键 显示的输出

Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row Template:Date table sorting/doc/row

文字换行[编辑]

要关闭自动换行的话,请使用nowrap=off参数。

高级用法[编辑]

除了内建格式,模板也支援使用以下变数自定义格式。

  1. 重定向 Template:Font color
格式代码 说明
%X 模板预设格式使用的年格式(不含“年”字)
%x 模板启用缩写后使用的年格式
%Y 年分,数字位数补0补到4位数
%y 年分,未补0
%M 月分,数字位数补0补到2位数
%m 月分,未补0
%D 日期,数字位数补0补到2位数
%d 日期,未补0
%% 跳脱
输入码 隐藏排序键 显示的输出

Template:Date table sorting/doc/row Template:Date table sorting/doc/row

注解[编辑]

排序非完整日期[编辑]

完整年份或月份[编辑]

完整年份或月份(或完整年月),例如{{dts|2020}}{{dts|Jan}}{{dts|2020|1}},系统会按其第一个日子排序。

没有年份[编辑]

如果未指定年份,系统将会视年份为现时年份来进行排序。

处理错误[编辑]

输入无效的日期格式(通常)会产生一条错误消息,例如Template:Tlx会产生以下内容:

Template:Dts

历法选择[编辑]

本模板无法区分儒略历和公历日期。另外,它不能从一个历法输入日期并按另一历法输出日期。所以,要确保排序良好,用户必须把日期统一于一个历法,或者确定一个转折日(例如,确定1582年10月4日为儒略历,以后的所有日期为公历),这可以用一条条的方法实现。如果可能造成混淆,用家有责任解释给读者究竟显示的日期是儒略历还是公历。

链接[编辑]

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

参见[编辑]

  • {{sort}},以一个特定的钥匙排序
  • {{sortname}},排序人名(用姓氏和名称作为预设排序钥匙)。
  • {{tts}},用于在体育赛事结果表中排序时间(只需要用于一定情况——参见该模板的文档页面)
  • {{number table sorting}},为数字而设