Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

natural-time-delta sorting - remove the splitter key and split by full keyword #366

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions sorting/natural-time-delta.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Created by Shodhan Save on Jan 23, 2018.
* Updated @ Jan 25, 2018
* Last updated @ Feb 13, 2018
*/

/**
Expand Down Expand Up @@ -37,20 +37,20 @@ jQuery.extend(jQuery.fn.dataTableExt.oSort,{
matches.reverse();

var time_elements = [
{"splitter" : "us", "name" : "microsecond", "mul" : 1 / 1000 / 1000},
{"splitter" : "ms", "name" : "millisecond", "mul" : 1 / 1000},
{"splitter" : "s", "name" : "second", "mul" : 1},
{"splitter" : "m", "name" : "minute", "mul" : 1 * 60},
{"splitter" : "h", "name" : "hour", "mul" : 1 * 60 * 60},
{"splitter" : "d", "name" : "day", "mul" : 1 * 60 * 60 * 24},
{"splitter" : "w", "name" : "week", "mul" : 1 * 60 * 60 * 24 * 7},
{"splitter" : "w", "name" : "month", "mul" : 1 * 60 * 60 * 24 * 7 * 30},
{"splitter" : "w", "name" : "year", "mul" : 1 * 60 * 60 * 24 * 7 * 30 * 12},
{"splitter" : "w", "name" : "decade", "mul" : 1 * 60 * 60 * 24 * 7 * 30 * 12 * 10},
{"name" : "microsecond", "mul" : 1 / 1000 / 1000},
{"name" : "millisecond", "mul" : 1 / 1000},
{"name" : "second", "mul" : 1},
{"name" : "minute", "mul" : 1 * 60},
{"name" : "hour", "mul" : 1 * 60 * 60},
{"name" : "day", "mul" : 1 * 60 * 60 * 24},
{"name" : "week", "mul" : 1 * 60 * 60 * 24 * 7},
{"name" : "month", "mul" : 1 * 60 * 60 * 24 * 7 * 30},
{"name" : "year", "mul" : 1 * 60 * 60 * 24 * 7 * 30 * 12},
{"name" : "decade", "mul" : 1 * 60 * 60 * 24 * 7 * 30 * 12 * 10},
];

time_elements.forEach(function(el, i){
var val = format_time_element(matches[i], el["splitter"], el["mul"]);
var val = format_time_element(matches[i], el.name, el.mul);
result += val;
});

Expand Down