Template:Dts/doc

 stands for  D ate  T able  S orting and is used to correctly sort and display dates in a sortable table (see Help:Tables).

What it solves
Normally, for proper sorting, dates must be entered in YYYY-MM-DD format. However, that format does not conform to the many books' manuals of style for date display. This template automatically creates the hidden  for sorting purposes and then displays the date like this: July 4, 1776. To hide the output, use the dtsh template instead.

Input




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  the maximum number of calls of this template on a page is 1200.

Using  produces a format that depends on, but is not necessarily equal to the format of the supplied date. This requires multiple calls of function, 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
Output sent to table
 * or

Output displayed to user
 * July 4, 1776 or
 * 4 July 1776

Linking
The template formerly linked dates automatically. To turn linking off the parameter  was used. In accordance with current guidelines linking is no longer supported. Please do not use this parameter. Please remove it from existing transclusions.

Abbreviating the month name
The template displays the name of the month either in abbreviated form or fully spelled out. There are two ways of controlling which is used. Note that the method to use is determined by the input. The first method works wherever the second method fails and only in these cases. The following explains which method to use.
 * 1) Directly input the desired format.
 * 2) Use the  parameter.

If the month is input as a number, the default is to spell it out in full. In this case the month can be abbreviated by setting  to.
 * All numeric input
 * gives "2000-01-01"
 * gives "2000-1-1"
 * gives "2000-01-01"
 * gives "2000-1-1"

The name of the month either in abbreviated form or fully spelled out when input as the second unnamed parameter. In either case the output form is equivalent to the input form.
 * Entering a non-numeric month as the second unnamed parameter
 * gives "January 1 2000"
 * gives "Jan 1 2000"

The if the whole date is entered as a single parameter with a non-numeric month, the default is to display the date as input. In this case either abbreviate or fully spelled out the name of the month as desired. Using the  parameter overrides this default behavior and the month name is spelled out in full by default. In this case the month can be abbreviated by setting  to.
 * The whole date as a single parameter with a non-numeric month
 * gives "1 January 2000"
 * gives "1 Jan 2000"
 * gives "1 January 2000"
 * gives "1 Jan 2000"
 * gives "1 January 2000"
 * gives "1 Jan 2000"

Error handling
Entering an invalid date format will (generally) produce an error message such as the one below. "35 June 1900"