Difference between revisions of "Template:Dts/doc"
Line 5: | Line 5: | ||
==What it solves== | ==What it solves== | ||
Normally, for proper sorting, dates must be entered in YYYY-MM-DD format. However, that format does not conform to the [[MOS:DATE|Manual of Style]] for date display. This template automatically creates the hidden <code><nowiki><span style="display:none">1776-07-04</span></nowiki></code> for sorting purposes and then displays the date like this: '''July 4, 1776'''. | Normally, for proper sorting, dates must be entered in YYYY-MM-DD format. However, that format does not conform to the [[MOS:DATE|Manual of Style]] for date display. This template automatically creates the hidden <code><nowiki><span style="display:none">1776-07-04</span></nowiki></code> for sorting purposes and then displays the date like this: '''July 4, 1776'''. | ||
− | |||
− | |||
− | |||
==Parameters== | ==Parameters== | ||
− | + | ===Dates=== | |
− | |||
− | |||
− | |||
− | |||
{|class=wikitable | {|class=wikitable | ||
|- | |- | ||
Line 45: | Line 38: | ||
|} | |} | ||
− | + | ;Input | |
{{tlf|dts|''year''|''month''|''day''|''BC''}} | {{tlf|dts|''year''|''month''|''day''|''BC''}} | ||
*{{<code>dts|1776|July|4</code>}} | *{{<code>dts|1776|July|4</code>}} | ||
Line 57: | Line 50: | ||
Also see the [[#Examples|examples]] below. | Also see the [[#Examples|examples]] below. | ||
− | + | ;Output | |
Output sent to table | Output sent to table | ||
*<code><nowiki><span style="display:none">01776-07-04-0000</span> July 4, 1776</nowiki></code> or | *<code><nowiki><span style="display:none">01776-07-04-0000</span> July 4, 1776</nowiki></code> or | ||
Line 65: | Line 58: | ||
*July 4, 1776 or | *July 4, 1776 or | ||
*4 July 1776 | *4 July 1776 | ||
− | |||
− | |||
− | |||
===Formatting=== | ===Formatting=== | ||
Line 147: | Line 137: | ||
*{{<code>dts|1 January 2000|abbr=on</code>}} gives "{{dts|1 January 2000|abbr=on}}" | *{{<code>dts|1 January 2000|abbr=on</code>}} gives "{{dts|1 January 2000|abbr=on}}" | ||
*{{<code>dts|2000|January|1|abbr=on</code>}} gives "{{dts|2000|January|1|abbr=on}}" | *{{<code>dts|2000|January|1|abbr=on</code>}} gives "{{dts|2000|January|1|abbr=on}}" | ||
+ | |||
+ | ===Wrapping=== | ||
+ | To turn off the suppression of word wraps, use the <code>nowrap=off</code> parameter. | ||
==Examples== | ==Examples== | ||
Line 189: | Line 182: | ||
|} | |} | ||
− | ==Error handling== | + | ==Notes== |
+ | ===Error handling=== | ||
Entering an invalid date format will (generally)<!--It's not quite perfect.--> produce an error message such as the one below. | Entering an invalid date format will (generally)<!--It's not quite perfect.--> produce an error message such as the one below. | ||
<blockquote>{{dts|35 June 1900}}</blockquote> | <blockquote>{{dts|35 June 1900}}</blockquote> | ||
+ | |||
+ | ===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. To turn linking off the parameter <code>link=off</code> was used. In accordance with current guidelines linking is no longer supported. Please do not use this parameter. Please remove it from existing transclusions. | ||
==See also== | ==See also== | ||
− | |||
* {{tl|TBA}}, allows quarters, and allows sorting of time periods by end date. | * {{tl|TBA}}, allows quarters, and allows sorting of time periods by end date. | ||
* {{tim|dts}}, since on Meta e.g. 09999 9999 induces numeric sort mode, "&" is prefixed to force string sort mode. | * {{tim|dts}}, since on Meta e.g. 09999 9999 induces numeric sort mode, "&" is prefixed to force string sort mode. |
Revision as of 05:14, 8 April 2014
This is a documentation subpage for Template:Dts. It contains 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).
Contents
What it solves
Normally, for proper sorting, dates must be entered in YYYY-MM-DD format. However, that format does not conform to the Manual of Style 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.
Parameters
Dates
{{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
{{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.
Also see the examples below.
- Output
Output sent to table
<span style="display:none">01776-07-04-0000</span> July 4, 1776
or<span style="display:none">01776-07-04-0000</span> 4 July 1776
Output displayed to user
- July 4, 1776 or
- 4 July 1776
Formatting
Using format
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. The format
parameter can take nine values.
value | function | example code | example output |
---|---|---|---|
dmy
|
displays the date in day-month-year format | {{dts|26 Jan 1888|format=dmy}}
|
26 Jan 1888 |
dm
|
displays only the day and month in day-month format | {{dts|26 Jan 1888|format=dm}}
|
26 Jan |
mdy
|
displays the date in month-day-year format (default) | {{dts|26 Jan 1888|format=mdy}}
|
Jan 26, 1888 |
md
|
displays only the day and month in month-day format | {{dts|26 Jan 1888|format=md}}
|
Jan 26 |
my
|
displays only the month and year in month-year format | {{dts|26 Jan 1888|format=my}}
|
Jan 1888 |
d
|
displays only the day | {{dts|26 Jan 1888|format=d}}
|
26 |
m
|
displays only the month | {{dts|26 Jan 1888|format=m}}
|
Jan |
y
|
displays only the year | {{dts|26 Jan 1888|format=y}}
|
1888 |
hide
|
hides the date | {{dts|26 Jan 1888|format=hide}}
|
Abbreviation
There are two ways of abbreviating the month name.
- Directly input the desired format.
- Use the
abbr
parameter.
- All-numeric input
If the month is input as a number, the default is to spell it out in full.
- {{
dts|2000-01-01
}} gives "January 1, 2000" - {{
dts|2000|1|1
}} gives "January 1, 2000"
In this case the month can be abbreviated by setting abbr
to on<code>.
- {{<code>dts|2000-01-01|abbr=on}} gives "Jan 1, 2000"
- {{
dts|2000|1|1|abbr=on
}} gives "Jan 1, 2000"
- Non-numeric input
When the month is entered either in abbreviated form or fully spelt out, the default is to output the input form.
- {{
dts|1 January 2000
}} gives "1 January 2000" - {{
dts|1 Jan 2000
}} gives "1 Jan 2000" - {{
dts|2000|January|1
}} gives "January 1, 2000" - {{
dts|2000|Jan|1
}} gives "Jan 1, 2000"
Setting abbr
to on<code> overrides this.
- {{<code>dts|1 January 2000|abbr=on}} gives "1 Jan 2000"
- {{
dts|2000|January|1|abbr=on
}} gives "Jan 1, 2000"
Wrapping
To turn off the suppression of word wraps, use the nowrap=off
parameter.
Examples
Template syntax | Hidden code | Visible date |
---|---|---|
{{dts|2001}}
|
2001 | |
{{dts|2001}}
|
2001 | |
{{dts||1|1}}
|
January 1 | |
{{dts|50|July}}
|
July 50 | |
{{dts|1000|July|4}}
|
July 4, 1000 | |
{{dts|5|July|4|BC}}
|
July 4, 5 BC | |
{{dts|40|July|4|BC}}
|
July 4, 40 BC | |
{{dts|1|July|4|BC}}
|
July 4, 1 BC | |
{{dts|88|July|4}}
|
July 4, 88 | |
{{dts|2007|7|11}}
|
July 11, 2007 | |
{{dts|2001|sep|11}}
|
Sep 11, 2001 | |
{{dts|2001|format=dmy}}
|
2001 | |
{{dts||1|1|format=dmy}}
|
1 January | |
{{dts|50|July|format=dmy}}
|
July 50 | |
{{dts|July|format=dmy}}
|
July | |
{{dts||July|format=dmy}}
|
July | |
{{dts|1000|July|4|format=dmy}}
|
4 July 1000 | |
{{dts|5|July|4|BC|format=dmy}}
|
4 July 5 BC | |
{{dts|40|July|4|BC|format=dmy}}
|
4 July 40 BC | |
{{dts|1|July|4|BC|format=dmy}}
|
4 July 1 BC | |
{{dts|88|July|4|format=dmy}}
|
4 July 88 | |
{{dts|2007|7|11|format=dmy}}
|
11 July 2007 | |
{{dts|2001|sep|11|format=dmy}}
|
11 Sep 2001 | |
{{dts|2001}}
|
2001 | |
{{dts|1 January}}
|
1 January | |
{{dts|July 19}}
|
July 19 | |
{{dts|July 1923}}
|
July 1923 | |
{{dts|10 July 1994}}
|
10 July 1994 | |
{{dts|July 4, 1555}}
|
July 4, 1555 | |
{{dts|24 Sep 2004}}
|
24 Sep 2004 | |
{{dts|1 July 1893|format=mdy}}
|
July 1, 1893 | |
{{dts|July 4, 1688|format=dmy}}
|
4 July 1688 | |
{{dts|2007-7-11|format=dmy}}
|
11 July 2007 | |
{{dts|2001-11-11}}
|
November 11, 2001 |
Notes
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
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. 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.
See also
- {{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.
- {{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