Template:Dts/doc
This is a documentation subpage for Template:Dts. It may contain usage information, categories and other content that is not part of the original template page. |
Dts/doc stands for Date Table Sorting and is used to correctly sort and display dates in a sortable table (see Help:Sorting).
What it solves
editNormally, for proper sorting, dates must be entered in YYYY-MM-DD format. However, that format does not conform to the for date display. This template automatically creates the hidden <span style="display:none">1776-07-04</span>
for sorting purposes and then displays the date like this: July 4, 1776. To hide the output, use the {{dtsh}} template instead.
Parameters
editDate display can be modified using two named parameters.
|
{{dts|year|month|day|BC}} | {{dts|date}} |
---|---|
Thus e.g. for the year 5 BC we can use "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. |
|
Input
edit{{dts|year|month|day|BC}}
- {{
dts|1776|July|4
}}
{{dts|date}}
- {{
dts|1776-07-04
}} - {{
dts|July 4, 1776
}} - {{
dts|4 July 1776
}}
When supplying a single parameter for the date, it is accepted and interpreted according to the php date/time format, except that a single number is interpreted as a year. By default the date is shown as supplied. If the first parameter is not just the year, but no format parameter is supplied, due to a call of function #time
the maximum number of calls of this template on a page is 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.
Also see the examples below.
Output
editOutput sent to table
<span style="display:none">01776-07-04</span> July 4, 1776
or<span style="display:none">01776-07-04</span> 4 July 1776
Output displayed to user
- July 4, 1776 or
- 4 July 1776
Linking
editThe template formerly linked dates automatically. To turn linking off the parameter link=off
was used. In accordance with current guidelines linking is no longer supported. Please do not use this parameter. Please remove it from existing transclusions.
Examples
editNormal function of the template. | The template with debug=yes , which causes hidden parts to appear:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Limitation
editTemplate:Dts/formauto calls #time
with format strings with a total length of up to 68 characters.
The worst case is when the default case of the #switch
applies, e.g. for the format 1876-08-25. In that case the template can only be called 88 times (here less because of the other examples):
August 25, 1801; August 25, 1802; August 25, 1803; August 25, 1804; August 25, 1805; August 25, 1806; August 25, 1807; August 25, 1808; August 25, 1809; August 25, 1810; August 25, 1811; August 25, 1812; August 25, 1813; August 25, 1814; August 25, 1815; August 25, 1816; August 25, 1817; August 25, 1818; August 25, 1819; August 25, 1820; August 25, 1821; August 25, 1822; August 25, 1823; August 25, 1824; August 25, 1825; August 25, 1826; August 25, 1827; August 25, 1828; August 25, 1829; August 25, 1830; August 25, 1831; August 25, 1832; August 25, 1833; August 25, 1834; August 25, 1835; August 25, 1836; August 25, 1837; August 25, 1838; August 25, 1839; August 25, 1840; August 25, 1841; August 25, 1842; August 25, 1843; August 25, 1844; August 25, 1845; August 25, 1846; August 25, 1847; August 25, 1848; August 25, 1849; August 25, 1850; August 25, 1851; August 25, 1852; August 25, 1853; August 25, 1854; August 25, 1855; August 25, 1856; August 25, 1857; August 25, 1858; August 25, 1859; August 25, 1860; August 25, 1861; August 25, 1862; August 25, 1863; August 25, 1864; August 25, 1865; August 25, 1866; August 25, 1867; August 25, 1868; August 25, 1869; August 25, 1870; August 25, 1871; August 25, 1872; August 25, 1873; August 25, 1874; August 25, 1875; August 25, 1876; August 25, 1877; August 25, 1878; August 25, 1879; August 25, 1880; August 25, 1881; August 25, 1882; August 25, 1883; August 25, 1884; August 25, 1885; Error: Too many #time calls.; Error: Too many #time calls.; Error: Too many #time calls.; Error: Too many #time calls.
Error handling
editDuring early 2009, Template:Dts generated month names for invalid month numbers, such as number 23 displaying "November". No warning is displayed, for the formatted page, that such invalid dates are being used on the page.
See also
edit- {{dtsh}}, hides the template's output
- {{TBA}}, allows quarters, and allows sorting of time periods by end date.
- m:Template:dts (backlinks, edit), since on Meta e.g. 09999 9999 induces numeric sort mode, "&" is prefixed to force string sort mode.
- {{dts1}}
- {{dts vgr}}, for video game release dates.
- {{sort}}, sorting by a specified key
- {{sortname}}, full name sorting.