Template talk:Date table sorting/Archive 1
![]() | This is an archive of past discussions about Template:Date table sorting. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Archive 1 | Archive 2 |
Expand the features
This template has no error checking for missing params, like day or month, and it should, since date can sort without them. It broke our Help:Sorting#Dates section, too! To convert existing tables in the DD-MM-YYYY format to something pretty, and to do it easily, it needs to be able to take the standard DD-MM-YYYY or DD-MM-YY format. In those cases, there would be no need to error check. Maybe it could just check parameter {{{1}}}, perhaps, for dashes and then directly print the full string hidden, then wikilinked, and Mediawiki will do the rest. Let me know if that part doesn't make sense. Sorry I can't figure out how to do that myself.—Wikibarista 17:16, 21 March 2007 (UTC)
Being used outside of sorted tables
The acronym is great, but unfortunately, it's being used incorrectly already by people to just put in dates anywhere in an article. We should rename it to "sortdate" to avoid misuse, because the misuse will cause pages to be larger when they're converted to HTML. —Wikibarista 18:02, 21 March 2007 (UTC)
Centralized discussion for all issues surrounding sortkeys for wikitables created here: Template talk:Sort. ~ trialsanderrors 09:02, 5 April 2007 (UTC)
Possible bugs
My Special:Preferences have the date presentation set to "2001-01-15T16:12:34". Yet when template is passed {{Dts|15|January|2001}}
I get the output of "15 January 2001". Surely I should be seeing the same output as what [[January 15]] [[2001]]
would give me, which is "2001-01-15". What's gone wrong? --Oscarthecat 16:46, 10 April 2007 (UTC)
- I fixed it, it was due to a blank space in the year link: [[12 April]] [[2007 ]] gives 12 April 2007 .--Patrick 07:25, 12 April 2007 (UTC)
- Thanks for the quick response Patrick. Yes, now working great. --Oscarthecat 20:32, 15 April 2007 (UTC)
Great work this weekend! I noted dts doesn't play nice with {{sortdate}} in the same table. I might be wrong on that, I'll have to look later. —Wikibarista 00:28, 17 April 2007 (UTC)
- A-ha, I see it. dts has a leading 0 whereas sortdate does not. —Wikibarista 00:35, 17 April 2007 (UTC)
- I have added the zero in sortdate.--Patrick 08:54, 3 May 2007 (UTC)
It seems like this template is breaking the sortable list of wii games, around the game "Wii Play". I have been unable to solve the problem, is any template coder capable of providing advanced help around? --User:Krator (t c) 14:43, 26 April 2007 (UTC)
- It seems the limit per Wikipedia:Template limits is reached on the page. --User:Krator (t c) 15:07, 26 April 2007 (UTC)
Change entry format from MM-DD-YYYY to YYYY-MM-DD
I motion that we change the entry format for this template from MM-DD-YYYY to YYYY-MM-DD. Pretty much all of the templates that require date entry are using YYYY-MM-DD ( {{Age in days}} is one I use often), and this should be changed to conform to that. I think that's standard - even the citation templates use that format. Gary King (talk) 02:36, 26 March 2008 (UTC)
Compatibility with WP:DATE
Based on recent changes to date formats (in particular, date autoformatting) in the Wikipedia:Manual of Style for dates, I would like to suggest that "link=off" should be the default setting so that dates are not automatically linked when not specifying a parameter (likely to be the most common usage). If editors wish to link dates, they can set "link=on". Truthanado (talk) 00:15, 15 September 2008 (UTC)
- A lot of people who use this template might then wonder why the links are now off; they might think something is broken, perhaps. Gary King (talk) 03:00, 15 September 2008 (UTC)
- That kind of confusion is already happening with the major change in the way dates are handled now. In the interest of moving forward to a consistent system, maybe that's an acceptable "bump in the road". Truthanado (talk) 11:32, 15 September 2008 (UTC)
- I don't mind; I created that feature in this template and would like to see the default as unlinked. But of course, I'm always a fan of consensus, too :) Gary King (talk) 14:14, 15 September 2008 (UTC)
- I think if the policy is to have unlinked dates, then the template ought to be made to be consistent with that policy. It is true that some people might think the template is broken, but then that should hopefully lead them to discover the change in policy, which would be a good thing in the long run! Mrh30 (talk) 09:27, 10 October 2008 (UTC)
You can set the default to be 'link=off' because all articles now use it for dts (and for the now deprecated dts2 template). The default will be useful for new uses. Lightmouse (talk) 13:30, 25 October 2008 (UTC)
Thanks. Lightmouse (talk) 17:37, 26 October 2008 (UTC)
Day and month without year?
I thought I had already asked this question, but apparently not. :) Is it possible to make this template display a date without the year, i.e. just day and month? PC78 (talk) 23:16, 23 October 2008 (UTC)
- No, not with its current setup. Gary King (talk) 23:20, 23 October 2008 (UTC)
- What I mean is, is it feasible to make this change to the template? PC78 (talk) 00:42, 24 October 2008 (UTC)
- This feature was not implemented probably because it wasn't requested that often. It can be done, though. In which article it is needed? Gary King (talk) 04:27, 24 October 2008 (UTC)
- I've been using it in articles such as List of South Korean films of 2006, where repeating the years seems rather redundant and takes up space. PC78 (talk) 13:39, 25 October 2008 (UTC)
- Okay done.
{{dts||10|25}}
will show as October 25; it will be sorted along with other dates that do have years, and it's year will be considered as whatever the current year is (so in this case, it would be sorted as2008-10-25
). Gary King (talk) 21:19, 25 October 2008 (UTC)- Many thanks! PC78 (talk) 13:21, 26 October 2008 (UTC)
- Okay done.
- I've been using it in articles such as List of South Korean films of 2006, where repeating the years seems rather redundant and takes up space. PC78 (talk) 13:39, 25 October 2008 (UTC)
- This feature was not implemented probably because it wasn't requested that often. It can be done, though. In which article it is needed? Gary King (talk) 04:27, 24 October 2008 (UTC)
- What I mean is, is it feasible to make this change to the template? PC78 (talk) 00:42, 24 October 2008 (UTC)
Approximate dates
Is it possible to use this table with approximate dates? I'm thinking of dates in the format "c.", "before", "after", "16/17 November" etc. The question relates to List of the titled nobility of England and Ireland 1300–1309 which is currently nominated for FL, where it has been suggested that a sortable list be used. I've found this problematic with so many approximate dates. Lampman (talk) 13:24, 21 February 2009 (UTC)
- That's not possible with the current code. Regarding implementing it, I think it'd be easier to write custom code for the specific article rather than rewriting this template. Just use {{sort}} to do what you want; the first parameter is for sorting, the second is for what you actually want to appear. Gary King (talk) 16:24, 21 February 2009 (UTC)
Retrofit talk-page year headers
19-Mar-2009: I have added subheaders above as "Topics from 2007-2008" (etc.) to emphasize the dates of topics in the talk-page. Older topics might still apply, but using the year headers helps to focus on more current issues as well. -Wikid77 (talk) 12:38, 19 March 2009 (UTC)
Template:Dts/ver for invalid dates
19-March-2009: I have created the temporary variation Template:Dts/ver to allow reporting invalid dates. That template could be merged at a later time, after options are fully developed.
Naturally, sometimes people are putting day-number for the month, where 21 gives "September" (21-12=9), 23 gives "November" etc. As in other templates, I was expecting an error-page-category, such as "Category:Template dts invalid month pages" which would silently list all pages with invalid month numbers passed to {{dts}}. Another method, coded in Template:Dts/ver, leaves the default behavior unchanged, but allows an optional verify-switch "v=yes" when invoking dts:
- {{dts/ver|v=yes |2009|78|55}} <--verify to report 78 & 55.
When a user sets "v=yes" then problems will display on the page:
- <br>Template:dts - month "78" > 12 in "2009|78|55".
- <br>Template:dts - day "55" > 31 in "2009|78|55".
That optional reporting allows each user to change pages to globally replace all "dts|" with "dts/ver|v=yes|" if they think those numbers should be reported. Of course, currently, the template handles any numbers for months/days, which some users might have assigned for special codes, such as day "32" sorts to the end of any month, so "v=yes" would be optional to allow day 32 (etc.) if used for special sorting.
See: Template:Dts/ver for more details. -Wikid77 (talk) 12:38, 19 March 2009 (UTC)
69% of omitted or swapped month/day are invalid
19-March-2009: Verifying the month/day can instantly detect problems in about 69% of cases, where month & day were swapped or month "12" was entered as "21". So verifying the date doesn't just find like 10% or 20% of problems, instead, verification finds almost two-thirds (65%) of all invalid, swapped dates. The total is, for days 13-31 being invalid months, and month "12" inverted as invalid "21":
- (31 - 12 + 1 for "21") / 31 = 20/31 ~= 64.52%.
Since November's month number 11 doesn't reverse, it is not a problem like December ("12" as "21"). However, if month or day are omitted, they are detected as "0" so that puts the chances of detecting an invalid date even higher than 65%, closer to 69%. Hence, computer-verified dates are a major advantage, in nearly 69% of those common data-entry errors. -Wikid77 (talk) 13:14, 19 March 2009 (UTC)
Nowrap
What about nowrap functionality? It is particularly useful for dates, which tend to get broken into two lines. Of course, one could say:
{{nowrap|{{dts|2009|1|1}}}}
but wouldn't
{{dts|nowrap=on|2009|1|1}}
be better? GregorB (talk) 19:29, 15 April 2009 (UTC)
- The template can be forced to nowrap by default if people think that makes more sense. There might be some fringe cases where that is unhelpful, though, like in a table where the columns are very narrow. Gary King (talk) 02:46, 16 April 2009 (UTC)
- Nowrap may well be the default but - as you've noted - this could cause problems (but to what extent, it's hard to say). What I had in mind is to add the nowrap option, but make it default to "off" so as to be on the safe side by not changing the behavior of existing transclusions. This could be the initial setup, at any rate. GregorB (talk) 06:52, 16 April 2009 (UTC)
- I tried to find an existing table that could cause problems with dts nowrap, but I could not find any. On the other hand, I found many that would benefit from nowrap. So yes, I'd say nowrap=on would really make sense as the default. GregorB (talk) 09:18, 16 April 2009 (UTC)
- Did it. The new parameter is "nowrap", and it defaults to "on". If there are major problems with this, feel free to revert. Minor problems in individual articles should be fixable by setting nowrap to "off"; I haven't found such cases thus far. I'll update the template documentation shortly. GregorB (talk) 12:05, 27 April 2009 (UTC)
Changes to the template
New functionality
I've added the capacity for the template to handle a date as a single parameter. The default formatting is the same (month-day-year) but only applies to ISO input (international format is left as is). It accepts abbreviated month names. It corrects capitilisation and comma mistakes. It uses {{#time:}} and so is limited to what the parser function can handle (e.g. it won't go beyond 100 AD). It ignores link=on
.
*ISO **{{dts|1990-09-03}} **{{dts|1990-09-03|format=dmy}} **{{dts|1990-09-03|format=mdy}} *International **{{dts|12 March 1990}} **{{dts|12 March 1990|format=dmy}} **{{dts|12 March 1990|format=mdy}} **{{dts|12 Mar 1990}} **{{dts|12 Mar 1990|format=dmy}} **{{dts|12 Mar 1990|format=mdy}} *US **{{dts|March 23, 1990}} **{{dts|March 23, 1990|format=dmy}} **{{dts|March 23, 1990|format=mdy}} **{{dts|Mar 23, 1990}} **{{dts|Mar 23, 1990|format=dmy}} **{{dts|Mar 23, 1990|format=mdy}} *Wrong **{{dts|12 March, 1990}} **{{dts|March 23 1990}} **{{dts|12 march 1990}} **{{dts|MARCH 23, 1990}} |
|
JIMp talk·cont 00:38, 4 August 2009 (UTC)
New coding
I've also somewhat rewritten the coding for the old functionality. There had been an error whereby |link=on|format=dmy
would give a date with month-day-year formatting. In the process of fixing that I changed the code a little. This invloved adding some subtemplates:
- Template:Dts/fmtdmy (edit | talk | history | links | watch | logs)
- Template:Dts/fmtmdy (edit | talk | history | links | watch | logs)
- Template:Dts/lkoff (edit | talk | history | links | watch | logs)
- Template:Dts/lkon (edit | talk | history | links | watch | logs)
The first two are for formatting & the second are for linking/nonlinking. JIMp talk·cont 00:50, 4 August 2009 (UTC)
Linking
I propose that the linking function
- not be mentioned on the doc page and
- eventually be removed.
Date linking is to be discouraged. Having it mentioned here as an option may give editors the impression that it's okay. Is there any conceivable reason to link dates in the sort of tables that this template is designed for?
Once we can be sure that there are no link=on
s left we could get rid of the option altogether. How can we be sure? Well, yes, there was something of an alterior motive to my fixing the template up. Here's the list of pages which have link=on
. JIMp talk·cont 01:01, 4 August 2009 (UTC)
- While I applaud heading in the direction of no linked dates, I plead for a different handling. First, an editor should not have to come here, to the discussion page, to find the meaning of the link parameter -- deprecated or not, it should be on the documentation page. Second, you don't need to wait until there's no more use of
link=on
-- just ignore it in the template code. Some dates that were linked will then come up not linked, but I'm all for that. The documentation page should then describelink=on
andlink=off
as former parameters that have no effect and should be removed when encountered.. . . . Jim . . . . Jameslwoodward (talk • contribs) 12:56, 22 September 2009 (UTC)
- Okay I readded it. Gary King (talk) 16:35, 22 September 2009 (UTC)
- So, Jim, you're suggesting the parameter be mentioned so that people can still make sense of transclusions which still use it. Presumably when there are no longer any such transclusions we can forget about it entirely, right. Note that there are no "
link=on
"s left. It shouldn't be too hard to eliminate any "link=off
"s that might exist. Once there are no "link=
"s at all we can safely put the issue to rest since it will only be of historical interest for which mention in talk archives is sufficient. I've changed the doc to better reflect the fact that this is a former parameter which should no longer be used & removed when found. JIMp talk·cont 17:45, 22 September 2009 (UTC)
- So, Jim, you're suggesting the parameter be mentioned so that people can still make sense of transclusions which still use it. Presumably when there are no longer any such transclusions we can forget about it entirely, right. Note that there are no "
- That's exactly what I wanted, but I had no idea how far along the elimination of "dts|link=" was. I did a search on "dts|link=off" and found only three hits. I edited them out and now a search on "dts|link=" (and variants with spaces in them) yields no hits except discussions. I don't know WP's search function well enough to be sure that's definitive, but it must be a pretty good indicator. So, I withdraw my request for including it in the documentation, except perhaps as a former parameter no longer usable, suggest that you eliminate it from the code, and apologize for jumping into the very end of a long process.. . . . Jim . . . . Jameslwoodward (talk • contribs) 11:19, 23 September 2009 (UTC)
Is this intentional?
For years BC we get a different hidden number depending on whether it's input as a negative year or as a year BC.
- {{
dts|1000|||BC|debug=yes
}} → "1000 BC" - {{
dts|-1000|debug=yes
}} → "1000 BC"
Is there a reason for this?
JIMp talk·cont 14:08, 4 August 2009 (UTC)
Accessibility problem
This template generates output that causes WP:ACCESSIBILITY problems. For example, "{{dts|1776|July|4}}
" generates output "July 4, 1776" that the Lynx text browser renders as "01776-07-04 July 4, 1776", and I assume that screen readers used by the visually impaired have similar misfires. Is this sort of problem inherent to what {{dts}} is trying to do with respect to sortable tables? At any rate, the bug (or accessibility issue) should be documented, no? Eubulides (talk) 07:26, 14 September 2009 (UTC)
- It's a huge problem with sortable tables in general. We can do better than the current implementation (i.e., not using display:none), but it would be a large undertaking. — RockMFR 22:55, 25 September 2009 (UTC)
- Ooo, ooo! You've got me on the edge of my seat with that tantalizing hint! Please tell us more! How can we do better? Eubulides (talk) 23:20, 25 September 2009 (UTC)
- We can create a custom sort key attribute for rows, then use that to enter sort keys rather than hiding them in CSS. We're already manipulating tables with JavaScript to sort, so this shouldn't be much more work. Gary King (talk) 00:40, 26 September 2009 (UTC)
- That's much better, thanks. And it doesn't sound like a "large undertaking", except for the conversion of existing pages (which would not have to be done all at once, of course; we could keep the old, buggy templates around for a while). Eubulides (talk) 01:30, 26 September 2009 (UTC)
- Yeah, that's pretty much what I was thinking. So if we wanted to go the attribute route, we would have to:
- Decide on an attribute name
- Add support for this attribute in MediaWiki (only certain attributes are allowed - the rest are stripped out)
- Add support for this attribute in the table sorting javascript code
- Convert existing pages to use new attribute instead of display:none — RockMFR 15:46, 26 September 2009 (UTC)
- We can create a custom sort key attribute for rows, then use that to enter sort keys rather than hiding them in CSS. We're already manipulating tables with JavaScript to sort, so this shouldn't be much more work. Gary King (talk) 00:40, 26 September 2009 (UTC)
- Ooo, ooo! You've got me on the edge of my seat with that tantalizing hint! Please tell us more! How can we do better? Eubulides (talk) 23:20, 25 September 2009 (UTC)
Add support for "12 Sept. 1928" and "12 Sep 1928" output.
Tables are often places where place is limited. Currently it always outputs the full month. There should be an option to have it output three letter months (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec) or AP style months (Jan., Feb., March, April, May, June, July, Aug., Sept., Oct., Nov., Dec.). Headbomb {ταλκκοντριβς – WP Physics} 23:45, 23 September 2009 (UTC)
- Three-letter dates are supported, e.g. {{
dts|31 Dec 2000
}} → "31 Dec 2000". JIMp talk·cont 13:57, 24 September 2009 (UTC)- Yes, but these involve lots of behind the scenes shenanigans and cannot be deployed in tables more than ~400 times per article before hitting a technical limit. What I have in mind is something more like
{{dts|2000|September|31|format=dmy|months=3L}} |
→ | (31 Sep 2000), |
{{dts|2000|09|31|format=dmy|months=3L}} |
→ | (31 Sep 2000), |
{{dts|2000|Sep|31|format=mdy|months=AP}} |
→ | (Sept. 31, 2000). |
- It looks fine to me. I ran Jim's version a thousand times and it still works. Gary King (talk) 18:22, 24 September 2009 (UTC)
- See [1]
- It looks fine to me. I ran Jim's version a thousand times and it still works. Gary King (talk) 18:22, 24 September 2009 (UTC)
- Is that a mistake? You've got
format=dmy
giving ymd. Has it yet been settled that we'll be using AP in tables (or at all)? JIMp talk·cont 19:44, 24 September 2009 (UTC)- No, he just hardcoded the text, that's why it's in YMD format; check the source code of his post. Gary King (talk) 19:48, 24 September 2009 (UTC)
- Yeah but it seems to imply that this'll be the output when you use
format=dmy
when it should be "31 Sep 2000". JIMp talk·cont 20:57, 24 September 2009 (UTC)- Mistake from my part, I've fixed it now. Headbomb {ταλκκοντριβς – WP Physics} 21:06, 24 September 2009 (UTC)
- Yeah but it seems to imply that this'll be the output when you use
- No, he just hardcoded the text, that's why it's in YMD format; check the source code of his post. Gary King (talk) 19:48, 24 September 2009 (UTC)
- I agree with Headbomb that this should be implemented, and through a switch in a parameter so that an existing table can be modified by simply adding the parameter to each entry. Jimp's kludge is a whole lot of unnecessary work if you have made a table one way, or some other editor has done so, and you decide to change it to abbreviate the months. Or to convert Jimp's format to spelled out months, for that matter. Gene Nygaard (talk) 22:33, 11 February 2010 (UTC)
Sort bug help
List of Kansas City Royals managers has a sort bug in the last column, labeled "WS". Can anybody figure it out? I know that this doesn't strictly concern {{dts}}, but this talk page is frequented by more editors so I thought I might as well give it a shot. Dabomb87 (talk) 00:06, 29 September 2009 (UTC)
- There's probably something wrong with the
ts_resortTable()
JavaScript function used to sort tables, because if you change thecolspan
in the bottom row to "2", then add another column in that row, then WS sorts fine. So it appears to be a bug in the sorting function. Gary King (talk) 00:39, 29 September 2009 (UTC)- Thanks, I have worked around that bug now. Dabomb87 (talk) 00:45, 29 September 2009 (UTC)
Template protected
I was surprised to see this template was unprotected, since this is being used in a lot of pages. Is there a particular reason this is not protected? I've just semi protected it indefinitely, but maybe it should be given full protection. ≈ Chamal talk ¤ 11:06, 24 October 2009 (UTC)
Template not working in certain pages
The template is not showing up in the List of WWE Tag Team Champions (under the date column) for me (and I asked on IRC, and it's not showing for other users as well and I tried both IE and Firefox). I checked the history, and I couldn't find a time when it did work, so it must be something in the template. What makes this weird is that it works perfectly on this page: List of World Tag Team Champions (WWE). Does anyone have any ideas as to what is going on? -- Scorpion0422 20:23, 23 December 2009 (UTC)
- The same issue came up on Avatar (2009 film). I just switched it to {{Start date}}. BOVINEBOY2008 :) 20:55, 23 December 2009 (UTC)
Works for me Gary King (talk) 19:11, 27 December 2009 (UTC)