Example full/complete date

Example full/complete date

AffNDOAffNDO Posts: 1Questions: 0Answers: 0
edited August 2012 in General
I'm new on the forum, but as I've been searching for a time and hadn't found exactly this, I want to share.
What I have give the name of Full Date, is the date formed by day (DD), month name, and year (YYYY), Ex: 07 August 2012.

The code was made for Portuguese dates, so is just change the months names.

[code]

"fulldate-pre": function ( a ) {
var fullDatea = a.split(' '); //split date in a array 0-day 1-month 2 year
var fullMonth = '';
switch (fullDatea[1].toUpperCase()){
case "JANEIRO":
fullMonth = '01';
break;
case "FEVEREIRO":
fullMonth = '02';
break;
case "MARCO":
fullMonth = '03';
break;
case "ABRIL":
fullMonth = '04';
break;
case "MAIO":
fullMonth = '05';
break;
case "JUNHO":
fullMonth = '06';
break;
case "JULHO":
fullMonth = '07';
break;
case "AGOSTO":
fullMonth = '08';
break;
case "SETEMBRO":
fullMonth = '09';
break;
case "OUTUBRO":
fullMonth = '10';
break;
case "NOVEMBRO":
fullMonth = '11';
break;
case "DEZEMBRO":
fullMonth = '12';
break;
}


return (fullDatea[2] + fullMonth + fullDatea[0]) * 1;

},

"fulldate-asc": function ( a, b ) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},

"fulldate-desc": function ( a, b ) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
},
[/code]

if someone find an error/mistake tells me.

-----------
I'm sorry for english rusty

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Excellent! Thanks very much for sharing this with us :-). Date / time is tricky because there are so many possible combinations - so it is always likely that an extra method, such as this might need to be crafted.

    It is worth me saying that sorting methods such as this can be wrapped up into plug-ins so you don't need to modify the DataTables source : http://datatables.net/development/sorting .

    Thanks,
    Allan
This discussion has been closed.