mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 05:31:15 -07:00
Fix rounding of seconds in user / library watch time stats
This commit is contained in:
parent
b9c1dccf48
commit
fcc70a9b74
1 changed files with 15 additions and 17 deletions
|
@ -288,25 +288,23 @@ function isPrivateIP(ip_address) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function humanTime(seconds) {
|
function humanTime(seconds) {
|
||||||
var text;
|
var d = Math.floor(moment.duration(seconds, 'seconds').asDays());
|
||||||
if (seconds >= 86400) {
|
var h = Math.floor(moment.duration((seconds % 86400), 'seconds').asHours());
|
||||||
text = '<h3>' + Math.floor(moment.duration(seconds, 'seconds').asDays()) + '</h3><p> days</p>' + '<h3>' +
|
var m = Math.round(moment.duration(((seconds % 86400) % 3600), 'seconds').asMinutes());
|
||||||
Math.floor(moment.duration((seconds % 86400), 'seconds').asHours()) + '</h3><p> hrs</p>' + '<h3>' +
|
|
||||||
Math.floor(moment.duration(((seconds % 86400) % 3600), 'seconds').asMinutes()) + '</h3><p> mins</p>';
|
var text = '';
|
||||||
return text;
|
if (d > 0) {
|
||||||
} else if (seconds >= 3600) {
|
text = '<h3>' + d + '</h3><p> day' + ((d > 1) ? 's' : '') + '</p>'
|
||||||
text = '<h3>' + Math.floor(moment.duration((seconds % 86400), 'seconds').asHours()) + '</h3><p> hrs</p>' +
|
+ '<h3>' + h + '</h3><p> hr' + ((h > 1) ? 's' : '') + '</p>'
|
||||||
'<h3>' + Math.floor(moment.duration(((seconds % 86400) % 3600), 'seconds').asMinutes()) +
|
+ '<h3>' + m + '</h3><p> min' + ((m > 1) ? 's' : '') + '</p>';
|
||||||
'</h3><p> mins</p>';
|
} else if (h > 0) {
|
||||||
return text;
|
text = '<h3>' + h + '</h3><p> hr' + ((h > 1) ? 's' : '') + '</p>'
|
||||||
} else if (seconds >= 60) {
|
+ '<h3>' + m + '</h3><p> min' + ((m > 1) ? 's' : '') + '</p>';
|
||||||
text = '<h3>' + Math.floor(moment.duration(((seconds % 86400) % 3600), 'seconds').asMinutes()) +
|
|
||||||
'</h3><p> mins</p>';
|
|
||||||
return text;
|
|
||||||
} else {
|
} else {
|
||||||
text = '<h3>0</h3><p> mins</p>';
|
text = '<h3>' + m + '</h3><p> min' + ((m > 1) ? 's' : '') + '</p>';
|
||||||
return text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
String.prototype.toProperCase = function () {
|
String.prototype.toProperCase = function () {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue