Template:Dts
From Wikipedia, the free encyclopedia
Dts stands for Date Table Sorting and is used to correctly sort and display dates in a sortable table (see Help:Sorting).
Contents |
[edit] What it solves
Normally, for proper sorting dates must be entered in YYYY-MM-DD format. But this does not conform to the Manual of Style for date display and wikilinking.
This template automatically creates the hidden <span style="display:none">1776-07-04</span> for sorting purposes and then displays and wikilinks the date properly like this July 4, 1776, depending on the user's Special:Preferences.
[edit] Parameters
- 1st parameter - Year
- Year number - number in the range -9999 through 9999: the numbers -9999 through 0 are used without "bc" and represent astronomical years -9999 through 0, the numbers 1 through 9999 represent that year AD, or BC with the fourth parameter set to bc or BC
- 2nd parameter - Month (optional if the day is not given either)
- Full month name - February or february
- Abbreviated month name - Feb or feb
- Month number - 2 or 02
- 3rd parameter - Day (optional)
- Day number - 7 or 07
- 4th parameter - optional with value BC or bc
- Used with a positive year number
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.
[edit] Input
{{Dts|1776|July|4}}
See also the examples.
[edit] Output
Output sent to table
<span style="display:none">1776-07-04</span> [[July 4]] [[1776]]
Output displayed to user
4 July 1776
[edit] See also
- Template:TBA (backlinks, edit) - 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
[edit] Examples
Examples with debug=yes (hidden parts are made visible):
| Template syntax | Date rendered |
|---|---|
| {{dts|debug=yes|9999||}} | 09999 9999 |
| {{dts|debug=yes|-50|July|}} | -9949-07 July 50 BC |
| {{dts|debug=yes|-1000|July|4}} | -8999-07-04 4 July 1000 BC |
| {{dts|debug=yes|5|July|4|BC}} | -9995-07-04 4 July 5 BC |
| {{dts|debug=yes|40|July|4|BC}} | -9960-07-04 4 July 40 BC |
| {{dts|debug=yes|1|July|4|BC}} | -9999-07-04 4 July 1 BC |
| {{dts|debug=yes|88|July|4}} | 00088-07-04 4 July 88 |
| {{dts|debug=yes|2007|7|11}} | 02007-07-11 11 July 2007 |
| {{dts|debug=yes|2001|sep|11}} | 02001-09-11 11 September 2001 |
| {{dts|debug=yes|2001||}} | 02001 2001 |
The same examples with hidden parts actually hidden:
| Template syntax | Date rendered |
|---|---|
| {{dts|9999||}} | 9999 |
| {{dts|-50|July|}} | July 50 BC |
| {{dts|-1000|July|4}} | 4 July 1000 BC |
| {{dts|5|July|4|BC}} | 4 July 5 BC |
| {{dts|40|July|4|BC}} | 4 July 40 BC |
| {{dts|1|July|4|BC}} | 4 July 1 BC |
| {{dts|88|July|4}} | 4 July 88 |
| {{dts|2007|7|11}} | 11 July 2007 |
| {{dts|2001|sep|11}} | 11 September 2001 |
| {{dts|2001||}} | 2001 |

