Commit 9a0b2dde authored by Tomas Pettersson's avatar Tomas Pettersson 🏸
Browse files

added diffToSlimFormat

parent 02009fef
......@@ -76,5 +76,58 @@ var STWkit = {
}
}
return urlParams;
},
diffToSlimFormat: function(diff) {
var result = '';
var parent = false;
var yr = diff.years;
if (yr > 0) {
var unit = ' yrs ';
if (yr == 1) unit = ' yr ';
result += yr + unit;
parent = true;
}
var mo = diff.months;
if (mo > 0 || parent) {
var unit = ' mo ';
if (mo == 1) unit = ' mo ';
result += mo + unit;
if (parent) return result;
parent = true;
}
var days = diff.days;
if (days > 0 || parent) {
var unit = ' days ';
if (days == 1) unit = ' day ';
result += days + unit;
if (parent) return result;
parent = true;
}
var hours = diff.hours;
if (hours > 0 || parent) {
var unit = ' hrs ';
if (hours == 1) unit = ' hr ';
result += hours + unit;
if (parent) return result;
parent = true;
}
var min = diff.minutes;
if (min > 0 || parent) {
var unit = ' min ';
if (min == 1) unit = ' min ';
result += min + unit;
if (parent) return result;
parent = true;
}
var sec = diff.seconds;
if (sec > 0 || parent) {
var unit = ' secs ';
if (sec == 1) unit = ' sec ';
result += sec + unit;
if (parent) return result;
parent = true;
}
return result;
}
};
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment