Template:Date table sorting/doc
| This is a documentation subpage for Template:Date table sorting It contains usage information, categories and other content that is not part of the original template page. |
| This template is used on approximately 28,000 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
| Abeg check well make sure say you really need this template before you use am. Default date sorting no dey work for dates wey month and year write full-full, or year–month combinations, and dates before year 100. But for most other situations e dey work fine. For more details, check Help:Sortable tables § Date sorting problems. |
| Dis template no suppose be used inside citation templates like Citation Style 1 and Citation Style 2, because e get markup wey go spoil the COinS metadata wey dem create; see Wikipedia:COinS. |
| This template uses Lua: |
Date table sorting dey help make dates inside sortable tables arrange correct and display well (see Help:Sortable tables).
Wetin e solve
[edit source]Dates wey people normally write, if you treat dem only like normal text letters and numbers, the sorting fit spoil:
- 1 September 1998 fit come before 5 March 1967 because the computer dey compare the first number, and 1 be smaller than 5;
- February 5, 1922 fit come before January 3, 1922 because F come before J alphabetically.
Using YYYY-MM-DD format fit solve this wahala, but apart from small exceptions, that format no dey normally use inside articles (see WP:DATEFORMAT).
This template automatically add one "hidden key" to dates. This hidden key make the dates sort correct, while people still dey see the normal formats like February 5, 1922, or 5 Feb 1922.
Parameters
[edit source]Dates
[edit source]{{Date table sorting|year|month|day|BC}} |
{{Date table sorting|date}} |
|---|---|
|
|
Formatting
[edit source]If you use one format inside the |format= parameter, like dmy, the output go depend on the format of the date wey you put inside, but e no always be exactly the same. The |format= parameter get nine different values wey you fit use.
Abbreviation
[edit source]There be two ways to shorten the month name.
- You fit directly enter the short version of the month name.
- You fit use the
|abbr=onparameter. You fit put am before or after the date inside the template. This one allow you shorten the month later if the table become too wide. You fit easily use find-and-replace inside text editor or wikitext editor to change{{Date table sorting|into{{Date table sorting|abbr=on|
Additional sort key
[edit source]If two dates for one table be exactly the same, you fit use the addkey parameter to decide which one go come first.
Wrapping
[edit source]Allowing dates to wrap fit help make one column and the whole table smaller. To allow wrapping, use the |nowrap=off parameter.
If you want make the table even tighter, use the |abbr=on parameter as explained before.
Both options help when tables too wide, when person dey use small screen, phone, or other devices.
TemplateData
[edit source]Date table sorting dey help make dates inside sortable tables arrange correct and display properly.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Full date or year | 1 | Full date if second to fourth parameters no dey specified, otherwise na year. Full date fit be in "YYYY-MM-DD", "DD-MM-YYYY", "DD Month YYYY", "Month DD, YYYY", "YYYY-MM", "DD Month", "Month DD", "Month YYYY" or "Month" format. Year fit be positive or negative number. If fourth parameter no dey, negative numbers dey mean years for BC era. Parameter fit be left empty if second parameter dey.
| String | required |
| Month | 2 | Full or short month name, or month number with or without zero before am. Parameter fit be left empty if third parameter no dey.
| String | optional |
| Day | 3 | Day number, whether zero dey before am or not
| Number | optional |
| Era | 4 | BC, AD, BCE or CE. E only work if first parameter be positive number. | String | optional |
| Format | format | Controls how the date go display. Values fit be "dmy", "dm", "mdy", "md", "my", "d", "m", "y" or "hide". | String | optional |
| Abbreviation | abbr | Makes the month name short
| String | optional |
| Additional sort key | addkey | Adds another hidden sorting key when two rows get the same date
| Number | optional |
| Wrapping | nowrap | To allow wrapping, use the ''nowrap=off'' parameter.
| Boolean | optional |
Notes
[edit source]Sorting for incomplete dates
[edit source]- Whole months or years: If you put only full year or full month (plus year), the system go sort am like the first day of that month or year.
- Missing years: If the year no dey inside the date, the system go treat am like say the year be the current year.
- Blank dates: If you no enter any date at all, the biggest possible sort key go use, so that entry go come last inside the table.
Calendar choice
[edit source]This template no fit know the difference between Julian calendar dates and Gregorian calendar dates.
E also no fit take date from one calendar and change am into another calendar.
So, if editors want make sorting correct, dem for either use only one calendar for all dates, or choose one particular date where the change happen (for example, deciding say 4 October 1582 be Julian and all dates after that be Gregorian).
Editors for make this decision based on the article wey dem dey work on.
Editors also get responsibility to explain to readers whether the dates wey dem dey see be Julian or Gregorian, especially if people fit get confused.
Linking
[edit source]Before, this template dey automatically link dates, and the |link=off parameter dey stop the linking.
But according to the current guidelines, date linking no dey supported again, so any |link=off wey remain inside pages for remove.
Error handling
[edit source]Errors from this template dey follow inside Category:Date table sorting templates with errors.
Dis be template wey go make wanna references make structured.
See also
[edit source]- {{sort}}, dey sort things by special key (e good for complicated numbers like scientific notation)
- {{sortname}}, dey arrange full names correctly (using "last name, first name" as default sorting key)
- {{tts}}, dey help sort times inside result tables for sports events (only needed for some special situations - see template documentation)
- {{Number table sorting}}, dey handle numbers
- {{Year in date-sorted table}}, dey sort years inside columns wey use
|data-sort-type=date
- ↑ Year 0 no dey exist and e go show error message
<ref> tags exist for a group named "lower-alpha", but no corresponding <references group="lower-alpha"/> tag was found.