diff --git a/data/interfaces/default/js/script.js b/data/interfaces/default/js/script.js index 7639de6e..1df0636f 100644 --- a/data/interfaces/default/js/script.js +++ b/data/interfaces/default/js/script.js @@ -288,25 +288,23 @@ function isPrivateIP(ip_address) { } function humanTime(seconds) { - var text; - if (seconds >= 86400) { - text = '
days
' + 'hrs
' + 'mins
'; - return text; - } else if (seconds >= 3600) { - text = 'hrs
' + - 'mins
'; - return text; - } else if (seconds >= 60) { - text = 'mins
'; - return text; + var d = Math.floor(moment.duration(seconds, 'seconds').asDays()); + var h = Math.floor(moment.duration((seconds % 86400), 'seconds').asHours()); + var m = Math.round(moment.duration(((seconds % 86400) % 3600), 'seconds').asMinutes()); + + var text = ''; + if (d > 0) { + text = 'day' + ((d > 1) ? 's' : '') + '
' + + 'hr' + ((h > 1) ? 's' : '') + '
' + + 'min' + ((m > 1) ? 's' : '') + '
'; + } else if (h > 0) { + text = 'hr' + ((h > 1) ? 's' : '') + '
' + + 'min' + ((m > 1) ? 's' : '') + '
'; } else { - text = 'mins
'; - return text; + text = 'min' + ((m > 1) ? 's' : '') + '
'; } + + return text } String.prototype.toProperCase = function () {