Jump to content

Template:Date table sorting/doc

From Wikipedia

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]

Template:Sticky-header

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.

  1. You fit directly enter the short version of the month name.
  2. You fit use the |abbr=on parameter. 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.

Examples
input code hidden sort key visible output

Template:Date table sorting/testcases/row Template:Date table sorting/testcases/row Template:Date table sorting/testcases/row Template:Date table sorting/testcases/row Template:Date table sorting/testcases/row Template:Date table sorting/testcases/row Template:Date table sorting/testcases/row

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.

Template parameters

ParameterDescriptionTypeStatus
Full date or year1

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.

Example
"1893", "-89", "-10000", "Oct", "February 1767", "12 Aug 1987", "July 1, 1867", "25 October", "Jan 1", "2014-12-09"
Stringrequired
Month2

Full or short month name, or month number with or without zero before am. Parameter fit be left empty if third parameter no dey.

Example
February, Feb, 2 or 02
Stringoptional
Day3

Day number, whether zero dey before am or not

Example
7 or 07
Numberoptional
Era4

BC, AD, BCE or CE. E only work if first parameter be positive number.

Stringoptional
Formatformat

Controls how the date go display. Values fit be "dmy", "dm", "mdy", "md", "my", "d", "m", "y" or "hide".

Stringoptional
Abbreviationabbr

Makes the month name short

Default
off
Example
on
Stringoptional
Additional sort keyaddkey

Adds another hidden sorting key when two rows get the same date

Example
3
Numberoptional
Wrappingnowrap

To allow wrapping, use the ''nowrap=off'' parameter.

Default
on
Example
off
Booleanoptional

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


  1. ↑ Year 0 no dey exist and e go show error message
Cite error: <ref> tags exist for a group named "lower-alpha", but no corresponding <references group="lower-alpha"/> tag was found.