Issue:Dates in sortable tables

From FollowTheScore
Revision as of 15:42, 9 September 2008 by Ianb1469 (talk | contribs) (New page: {{Issue |Type = Bug |Extension = DPL |Version = |Description = DPL does not allow sortable dates in tables |Status = open }} == Problem == The dpl output for a tab...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Description: DPL does not allow sortable dates in tables
Extension / Version: DPL   /  
Type / Status: Bug   /   open

Problem

The dpl output for a table in dates in it does not allow mediawiki data-sorting to work correctly.

  • The mediawiki date sorting is very strict (wikibits.js) about what it recognises as a date. For example, for "01/02/2009" to be a date, it must have a length of exactly 10 characters and match a regular expression /^\d\d[\/.-]\d\d[\/.-]\d\d\d\d$/ (notice the start and end markers).
  • The output from a DPL table contains extra characters (newline) that mean that an apparent date is not treated as so.
<tr>
<td><a href="/mediawiki/index.php/Cust1" title="Cust1">Cust1</a>
</td><td>01/02/2009
</td></tr>

Test case: Page Template:datetest contains

{{{date}}}

A page contains:

{{datetest|date=01/02/2009}}
{{datetest|date=03/11/2009}}
{{datetest|date=03/10/2009}}
{{datetest|date=03/12/2009}}
{{datetest|date=03/02/2010}}

Then the DPL script:

<dpl>
 uses=Template:Datetest
 include={Datetest}:date
 table=class="wikitable sortable",page,date
</dpl>

Generates this output (after sorting)

C1 	01/02/2009 
C1 	03/11/2009 
C1 	03/10/2009 
C1 	03/12/2009 
C1 	03/02/2010

Note that there is a line in wikibits.js that needs to be carefully adjusted...but in this case, it does not make a difference because the js is failing to recognise it as a date earlier than this.

var ts_europeandate = wgContentLanguage != "en";  //The non-American-inclined can change to "true"


Reply