Template:Dts
{{#ifeq:dts |doc
|
{{#ifeq:show |show
|This is a documentation subpage for Template:Dts. It contains usage information, categories and other content that is not part of the original {{#if: |{{{text2}}} |{{#if: |{{{text1}}} |{{#ifeq:Template |User |template template page |{{#if:Template |template page|article}}}}}}}}. |
}}{{#if: | | {{#ifexist:Template:Dts | [[Category:{{#switch:Template |Template=Template |Module=Module |User=User |#default=Wikipedia}} documentation pages]] | }} }} | }}
This {{#switch:Template|Module=Lua module|#default=template}} is used on [https://tools.wmflabs.org/templatecount/index.php?lang=en&namespace=10&name=%7B%7B%0A%23switch%3A+Dts%0A%7C+doc+%7C+sandbox+%3D+Dts%0A%7C+%23default++++++%3D+Dts%0A%7D%7D {{#iferror:{{#expr:0+{{#ifeq:yes|yes|20200+|20200+}}*1}}|many|approximately {{#ifeq:{{#ifeq:yes|yes|20200+|20200+}}|0
|0 |{{significant figures/{{#if:2 |rnd |sum }} |1={{#ifeq:yes|yes|20200+|20200+}} |2=2 |3={{safesubst:#ifexpr:{{#ifeq:yes|yes|20200+|20200+}}=0 |{{safesubst:#ifexpr:abs{{#ifeq:yes|yes|20200+|20200+}}1=1 |0 |{{safesubst:#expr:floor((ln(abs{{#ifeq:yes|yes|20200+|20200+}}1)/ln10)+1)}} }} |{{#expr:floor((ln(abs({{#ifeq:yes|yes|20200+|20200+}}) )/ln 10)+1E((abs{{#ifeq:yes|yes|20200+|20200+}}>1E100 or abs{{#ifeq:yes|yes|20200+|20200+}}<1E-100)-14))}} }} }} }}}} pages], so changes to it will be widely noticed. Please test any changes in the {{#switch:Template|Module=module's|#default=template's}} [[{{#switch: Dts | doc | sandbox = Template:Dts | #default = Template:Dts }}/sandbox|/sandbox]] or [[{{#switch: Dts | doc | sandbox = Template:Dts | #default = Template:Dts }}/testcases|/testcases]] subpages{{#switch:Template|Module=.|#default=, or in your own user subpage.}} Please consider discussing changes {{#if:|at [[{{{2}}}]]|on the [[{{#switch: Dts | doc | sandbox = Template talk:Dts | #default = Template talk:Dts}}|talk page]]}} before implementing them. |
Please check that you do actually need this template before using it. Default date sorting does not work for spelled-out month–year or year–month combos and dates before the year 100, but it works in most other circumstances. Furthermore, this template litters the text content of tables, and data-sort-value should generally be preferred. For more information, see Help:Sorting § Date sorting problems. |
{{#if:{{#ifeq: n|n|Stop hand nuvola.svg}} |[[File:{{#ifeq: n|n|Stop hand nuvola.svg}}|40px|Notice]]}} | {{#if: | ' }}{{#ifeq: n|n
|This template should not be used in citation templates such as Citation Style 1 and Citation Style 2, because it includes markup that will pollute the COinS metadata they produce; see COinS in Wikipedia. |This template is safe for use in citation templates that produce COinS metadata; see COinS in Wikipedia. If HTML or other markup is added, then the template must be reevaluated.}} | {{#if: |{{{imageright}}} |{{#if: |Template:Ombox/shortcut}} }} |
Uses Lua: |
Dts (date time sorting) is used to correctly sort and display dates in a sortable table (see Help:Sorting).
Contents
What it solves
Dates in their customary formats, if simply treated as alphanumeric text strings, sort in nonsensical ways:
- 1/8/2013 sorts alphanumerically before 5/3/1967, because 1 is less than 5;
- February 5, 1922 sorts alphanumerically before January 3, 1922, because F comes before J.
Use of the YYYY-MM-DD format would solve this problem, but with minor exceptions that format is not used in articles (see WP:DATEFORMAT).
This template automatically attaches a "hidden key" to dates, causing them to sort correctly while still being displayed in one of the customary display formats such as February 5, 1922 or 5 Feb 1922.
Parameters
Dates
{{{{#if:dts|dts| tlf|...}}{{#ifeq:year|year| |year | }}{{#ifeq:month|month| |month | }}{{#ifeq:day|day| |day | }}{{#ifeq:BC|BC| |BC | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}}} | {{{{#if:dts|dts| tlf|...}}{{#ifeq:date|date| |date | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}}} |
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
input style | input code | hidden sort key | visible output | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{{{{#if:dts|dts| tlf|...}}{{#ifeq:year|year| |year | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|1893|||{{{4}}} | {{#if: | |1893||{{{3}}} | {{#if: | |1893|{{{2}}} | {{#if:1893 | |1893
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | 1893
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|-89|||{{{4}}} | {{#if: | |-89||{{{3}}} | {{#if: | |-89|{{{2}}} | {{#if:-89 | |-89
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | 89 BC
}} | ||||||||
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|-10000|||{{{4}}} | {{#if: | |-10000||{{{3}}} | {{#if: | |-10000|{{{2}}} | {{#if:-10000 | |-10000
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | 10,000 BC
}} | ||||||||
{{{{#if:dts|dts| tlf|...}}{{#ifeq:month|month| |month | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|Oct|||{{{4}}} | {{#if: | |Oct||{{{3}}} | {{#if: | |Oct|{{{2}}} | {{#if:Oct | |Oct
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | Oct
}} | |
{{{{#if:dts|dts| tlf|...}}{{#ifeq:month year|month year| |month year | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|February 1767|||{{{4}}} | {{#if: | |February 1767||{{{3}}} | {{#if: | |February 1767|{{{2}}} | {{#if:February 1767 | |February 1767
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | February 1767
}} | |
{{{{#if:dts|dts| tlf|...}}{{#ifeq:day month year|day month year| |day month year | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|12 Aug 1987|||{{{4}}} | {{#if: | |12 Aug 1987||{{{3}}} | {{#if: | |12 Aug 1987|{{{2}}} | {{#if:12 Aug 1987 | |12 Aug 1987
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | 12 Aug 1987
}} | |
{{{{#if:dts|dts| tlf|...}}{{#ifeq:month day, year|month day, year| |month day, year | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|July 1, 1867|||{{{4}}} | {{#if: | |July 1, 1867||{{{3}}} | {{#if: | |July 1, 1867|{{{2}}} | {{#if:July 1, 1867 | |July 1, 1867
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | July 1, 1867
}} | |
{{{{#if:dts|dts| tlf|...}}{{#ifeq:day month|day month| |day month | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|25 October|||{{{4}}} | {{#if: | |25 October||{{{3}}} | {{#if: | |25 October|{{{2}}} | {{#if:25 October | |25 October
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | 25 October
}} | |
{{{{#if:dts|dts| tlf|...}}{{#ifeq:month day|month day| |month day | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|Jan 1|||{{{4}}} | {{#if: | |Jan 1||{{{3}}} | {{#if: | |Jan 1|{{{2}}} | {{#if:Jan 1 | |Jan 1
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | Jan 1
}} | |
{{{{#if:dts|dts| tlf|...}}{{#ifeq:YYYY-MM-DD|YYYY-MM-DD| |YYYY-MM-DD | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2014-12-09|||{{{4}}} | {{#if: | |2014-12-09||{{{3}}} | {{#if: | |2014-12-09|{{{2}}} | {{#if:2014-12-09 | |2014-12-09
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | December 9, 2014
}} | |
{{{{#if:dts|dts| tlf|...}}{{#ifeq:year|year| |year | }}{{#ifeq:month|month| |month | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|1990|10||{{{4}}} | {{#if: | |1990|10|{{{3}}} | {{#if:10 | |1990|10 | {{#if:1990 | |1990
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | October 1990
}} | ||
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|1980|Dec||{{{4}}} | {{#if: | |1980|Dec|{{{3}}} | {{#if:Dec | |1980|Dec | {{#if:1980 | |1980
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | Dec 1980
}} | ||||||||
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|1970|August||{{{4}}} | {{#if: | |1970|August|{{{3}}} | {{#if:August | |1970|August | {{#if:1970 | |1970
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | August 1970
}} | ||||||||
{{{{#if:dts|dts| tlf|...}}{{#ifeq:year|year| |year | }}{{#ifeq:month|month| |month | }}{{#ifeq:day|day| |day | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2024|Jun|12|{{{4}}} | {{#if:12 | |2024|Jun|12 | {{#if:Jun | |2024|Jun | {{#if:2024 | |2024
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | Jun 12, 2024
}} | |||
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|-204|11|22|{{{4}}} | {{#if:22 | |-204|11|22 | {{#if:11 | |-204|11 | {{#if:-204 | |-204
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | November 22, 204 BC
}} | ||||||||
{{{{#if:dts|dts| tlf|...}}{{#ifeq:year|year| |year | }}{{#ifeq:month|month| |month | }}{{#ifeq:day|day| |day | }}{{#ifeq:era|era| |era | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|44|3|15|BC | {{#if:15 | |44|3|15 | {{#if:3 | |44|3 | {{#if:44 | |44
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | March 15, 44 BC
}} | ||||
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|94|Oct|17|AD | {{#if:17 | |94|Oct|17 | {{#if:Oct | |94|Oct | {{#if:94 | |94
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | Oct 17, 94
}} | ||||||||
{{{{#if:dts|dts| tlf|...}}{{#ifeq: | }}{{#ifeq:month|month| |month | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}}}|
}}{{#if:| |
{{{b}}}|
}}| |
||May||{{{4}}} | {{#if: | ||May|{{{3}}} | {{#if:May | ||May | {{#if: | |
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | May
}} | |
{{{{#if:dts|dts| tlf|...}}{{#ifeq: | }}{{#ifeq:month|month| |month | }}{{#ifeq:day|day| |day | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}{{#ifeq:x | }}}}|
}}{{#if:| |
{{{b}}}|
}}| |
||Sep|12|{{{4}}} | {{#if:12 | ||Sep|12 | {{#if:Sep | ||Sep | {{#if: | |
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | Sep 12
}} |
Formatting
Using format
produces a format that depends on, but is not necessarily equal to the format of the supplied date. The format
parameter can take nine values.
value | function | input code | hidden sort key | visible output | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
}}{{#if:format depends on the input| |
format depends on the input|
}}| |
|26 Jan 1788|||{{{4}}} | {{#if: | |26 Jan 1788||{{{3}}} | {{#if: | |26 Jan 1788|{{{2}}} | {{#if:26 Jan 1788 | |26 Jan 1788
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | 26 Jan 1788
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|March 12, 1557|||{{{4}}} | {{#if: | |March 12, 1557||{{{3}}} | {{#if: | |March 12, 1557|{{{2}}} | {{#if:March 12, 1557 | |March 12, 1557
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | March 12, 1557
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|1975-02-13|||{{{4}}} | {{#if: | |1975-02-13||{{{3}}} | {{#if: | |1975-02-13|{{{2}}} | {{#if:1975-02-13 | |1975-02-13
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | February 13, 1975
}} | |
dmy |
}}{{#if:displays the date in day-month-year format| |
displays the date in day-month-year format|
}}| |
|Sep 13, 1888|||{{{4}}} | {{#if: | |Sep 13, 1888||{{{3}}} | {{#if: | |Sep 13, 1888|{{{2}}} | {{#if:Sep 13, 1888 | |Sep 13, 1888
}} }} }} }}{{#if:dmy |
|format=dmy
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | 13 Sep 1888
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|1983-01-03|||{{{4}}} | {{#if: | |1983-01-03||{{{3}}} | {{#if: | |1983-01-03|{{{2}}} | {{#if:1983-01-03 | |1983-01-03
}} }} }} }}{{#if:dmy |
|format=dmy
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | 3 January 1983
}} | |
dm |
}}{{#if:displays only the day and month in day-month format| |
displays only the day and month in day-month format|
}}| |
|Feb 26, 1788|||{{{4}}} | {{#if: | |Feb 26, 1788||{{{3}}} | {{#if: | |Feb 26, 1788|{{{2}}} | {{#if:Feb 26, 1788 | |Feb 26, 1788
}} }} }} }}{{#if:dm |
|format=dm
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | 26 Feb
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2020-10-15|||{{{4}}} | {{#if: | |2020-10-15||{{{3}}} | {{#if: | |2020-10-15|{{{2}}} | {{#if:2020-10-15 | |2020-10-15
}} }} }} }}{{#if:dm |
|format=dm
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | 15 October
}} | |
mdy |
}}{{#if:displays the date in month-day-year format| |
displays the date in month-day-year format|
}}| |
|August 31, 1901|||{{{4}}} | {{#if: | |August 31, 1901||{{{3}}} | {{#if: | |August 31, 1901|{{{2}}} | {{#if:August 31, 1901 | |August 31, 1901
}} }} }} }}{{#if:mdy |
|format=mdy
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | August 31, 1901
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2006-11-08|||{{{4}}} | {{#if: | |2006-11-08||{{{3}}} | {{#if: | |2006-11-08|{{{2}}} | {{#if:2006-11-08 | |2006-11-08
}} }} }} }}{{#if:mdy |
|format=mdy
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | November 8, 2006
}} | |
md |
}}{{#if:displays only the day and month in month-day format| |
displays only the day and month in month-day format|
}}| |
|26 Jun 1988|||{{{4}}} | {{#if: | |26 Jun 1988||{{{3}}} | {{#if: | |26 Jun 1988|{{{2}}} | {{#if:26 Jun 1988 | |26 Jun 1988
}} }} }} }}{{#if:md |
|format=md
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | Jun 26
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2002-02-27|||{{{4}}} | {{#if: | |2002-02-27||{{{3}}} | {{#if: | |2002-02-27|{{{2}}} | {{#if:2002-02-27 | |2002-02-27
}} }} }} }}{{#if:md |
|format=md
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | February 27
}} | |
my |
}}{{#if:displays only the month and year in month-year format| |
displays only the month and year in month-year format|
}}| |
|16 November 1488|||{{{4}}} | {{#if: | |16 November 1488||{{{3}}} | {{#if: | |16 November 1488|{{{2}}} | {{#if:16 November 1488 | |16 November 1488
}} }} }} }}{{#if:my |
|format=my
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | November 1488
}} | |
d |
}}{{#if:displays only the day| |
displays only the day|
}}| |
|6 July 1666|||{{{4}}} | {{#if: | |6 July 1666||{{{3}}} | {{#if: | |6 July 1666|{{{2}}} | {{#if:6 July 1666 | |6 July 1666
}} }} }} }}{{#if:d |
|format=d
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | 6
}} | |
m |
}}{{#if:displays only the month| |
displays only the month|
}}| |
|1980-02-12|||{{{4}}} | {{#if: | |1980-02-12||{{{3}}} | {{#if: | |1980-02-12|{{{2}}} | {{#if:1980-02-12 | |1980-02-12
}} }} }} }}{{#if:m |
|format=m
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | February
}} | |
y |
}}{{#if:displays only the year| |
displays only the year|
}}| |
|-26|Jan|18|{{{4}}} | {{#if:18 | |-26|Jan|18 | {{#if:Jan | |-26|Jan | {{#if:-26 | |-26
}} }} }} }}{{#if:y |
|format=y
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | 26 BC
}} | |
hide |
}}{{#if:hides the date| |
hides the date|
}}| |
|15 October 1800|||{{{4}}} | {{#if: | |15 October 1800||{{{3}}} | {{#if: | |15 October 1800|{{{2}}} | {{#if:15 October 1800 | |15 October 1800
}} }} }} }}{{#if:hide |
|format=hide
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | }} |
Abbreviation
There are two ways of abbreviating the month name.
- Directly input an abbreviated month name.
- Use the
abbr=on
parameter.
abbreviation method | input code | hidden sort key | visible output | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
none|
}}{{#if:| |
{{{b}}}|
}}| |
|2000-01-01|||{{{4}}} | {{#if: | |2000-01-01||{{{3}}} | {{#if: | |2000-01-01|{{{2}}} | {{#if:2000-01-01 | |2000-01-01
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | January 1, 2000
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2000|1|1|{{{4}}} | {{#if:1 | |2000|1|1 | {{#if:1 | |2000|1 | {{#if:2000 | |2000
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | January 1, 2000
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|1 January 2000|||{{{4}}} | {{#if: | |1 January 2000||{{{3}}} | {{#if: | |1 January 2000|{{{2}}} | {{#if:1 January 2000 | |1 January 2000
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | 1 January 2000
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2000|January|1|{{{4}}} | {{#if:1 | |2000|January|1 | {{#if:January | |2000|January | {{#if:2000 | |2000
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | January 1, 2000
}} | |
abbreviated input|
}}{{#if:| |
{{{b}}}|
}}| |
|1 Jan 2000|||{{{4}}} | {{#if: | |1 Jan 2000||{{{3}}} | {{#if: | |1 Jan 2000|{{{2}}} | {{#if:1 Jan 2000 | |1 Jan 2000
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | 1 Jan 2000
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2000|Jan|1|{{{4}}} | {{#if:1 | |2000|Jan|1 | {{#if:Jan | |2000|Jan | {{#if:2000 | |2000
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | Jan 1, 2000
}} | |
abbr=on |
}}{{#if:| |
{{{b}}}|
}}| |
|1 January 2000|||{{{4}}} | {{#if: | |1 January 2000||{{{3}}} | {{#if: | |1 January 2000|{{{2}}} | {{#if:1 January 2000 | |1 January 2000
}} }} }} }}{{#if: |
|format=
}}{{#if:on |
|abbr=on
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | 1 Jan 2000
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2000|January|1|{{{4}}} | {{#if:1 | |2000|January|1 | {{#if:January | |2000|January | {{#if:2000 | |2000
}} }} }} }}{{#if: |
|format=
}}{{#if:on |
|abbr=on
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | Jan 1, 2000
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2000-01-01|||{{{4}}} | {{#if: | |2000-01-01||{{{3}}} | {{#if: | |2000-01-01|{{{2}}} | {{#if:2000-01-01 | |2000-01-01
}} }} }} }}{{#if: |
|format=
}}{{#if:on |
|abbr=on
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | Jan 1, 2000
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2000|1|1|{{{4}}} | {{#if:1 | |2000|1|1 | {{#if:1 | |2000|1 | {{#if:2000 | |2000
}} }} }} }}{{#if: |
|format=
}}{{#if:on |
|abbr=on
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | Jan 1, 2000
}} |
Additional sort key
In case two dates in a table are identical they may be ordered using the addkey
parameter.
input code | hidden sort key | visible output | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2010-10-10|||{{{4}}} | {{#if: | |2010-10-10||{{{3}}} | {{#if: | |2010-10-10|{{{2}}} | {{#if:2010-10-10 | |2010-10-10
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if:3 |
|addkey=3
}}}} {{#if: |
Template:Dts/testcases/colour | October 10, 2010
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2010-10-09|||{{{4}}} | {{#if: | |2010-10-09||{{{3}}} | {{#if: | |2010-10-09|{{{2}}} | {{#if:2010-10-09 | |2010-10-09
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | October 9, 2010
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2010-10-10|||{{{4}}} | {{#if: | |2010-10-10||{{{3}}} | {{#if: | |2010-10-10|{{{2}}} | {{#if:2010-10-10 | |2010-10-10
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if:1 |
|addkey=1
}}}} {{#if: |
Template:Dts/testcases/colour | October 10, 2010
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2010-10-10|||{{{4}}} | {{#if: | |2010-10-10||{{{3}}} | {{#if: | |2010-10-10|{{{2}}} | {{#if:2010-10-10 | |2010-10-10
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | October 10, 2010
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2010-10-10|||{{{4}}} | {{#if: | |2010-10-10||{{{3}}} | {{#if: | |2010-10-10|{{{2}}} | {{#if:2010-10-10 | |2010-10-10
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if:4 |
|addkey=4
}}}} {{#if: |
Template:Dts/testcases/colour | October 10, 2010
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2010-10-11|||{{{4}}} | {{#if: | |2010-10-11||{{{3}}} | {{#if: | |2010-10-11|{{{2}}} | {{#if:2010-10-11 | |2010-10-11
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if: |
|addkey=
}}}} {{#if: |
Template:Dts/testcases/colour | October 11, 2010
}} | |
{{{a}}}|
}}{{#if:| |
{{{b}}}|
}}| |
|2010-10-10|||{{{4}}} | {{#if: | |2010-10-10||{{{3}}} | {{#if: | |2010-10-10|{{{2}}} | {{#if:2010-10-10 | |2010-10-10
}} }} }} }}{{#if: |
|format=
}}{{#if: |
|abbr=
}}{{#if:2 |
|addkey=2
}}}} {{#if: |
Template:Dts/testcases/colour | October 10, 2010
}} |
Wrapping
To turn off the suppression of word wraps, use the nowrap=off
parameter.
Notes
Sorting for incomplete dates
- Whole months or years
- A whole year or month (and year) is sorted according to its first day.
- Missing years
- If the year is not specified, the date will be sorted as if the year were the current year.
- Blank dates
- For no date input at all, the maximum possible sort key is used, so the entry will sort last.
Error handling
Entering an invalid date format will (generally) produce an error message such as the one below.
Error in Template:Dts: days must be an integer between 1 and 31
Errors are tracked in Category:Dts templates with errors.
Calendar choice
The template is not capable of distinguishing Julian and Gregorian calendar dates. Also, it is not capable of taking a date in one calendar as input and outputting a date in the other calendar. Thus, to insure proper sorting, editors must either use one calendar for all dates, or pick a specific changeover date (for example, deciding that 4 October 1582 is Julian and all later dates are Gregorian); this would be done on an article-by article basis. Editors are also responsible for explaining to the reader whether the visible dates are Julian or Gregorian, if there is any possibility of confusion.
Linking
The template formerly linked dates automatically, with link=off
used to suppress linking. In accordance with current guidelines linking of dates is no longer supported and instances of link=off
should be removed. Transclusions using the |{{#if:link|link=}}
parameter are tracked in Category:Dts templates with deprecated parameters.
See also
- m:Template:dts {{#if:(backlinks edit)
|(backlinks edit) |90% }}, since on Meta e.g. 09999 9999 induces numeric sort mode, "&" is prefixed to force string sort mode.
- {{sort}}, sorting by a specified key (also good for complicated numbers, e.g. scientific notation)
- {{sortname}}, full name sorting (using "last name, first name" as default sort key)
- {{tts}}, for sorting times in result tables of athletic events (only needed in certain cases - see template documentation)
- {{mss}}, for sorting times in tables of eclipses
- {{nts}}, for numbers
{{#ifeq:Dts|sandbox | |
}}
The above documentation is transcluded from Template:Dts/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |