mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 13:11: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) {
|
||||
var text;
|
||||
if (seconds >= 86400) {
|
||||
text = '<h3>' + Math.floor(moment.duration(seconds, 'seconds').asDays()) + '</h3><p> days</p>' + '<h3>' +
|
||||
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>';
|
||||
return text;
|
||||
} else if (seconds >= 3600) {
|
||||
text = '<h3>' + 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>';
|
||||
return text;
|
||||
} else if (seconds >= 60) {
|
||||
text = '<h3>' + Math.floor(moment.duration(((seconds % 86400) % 3600), 'seconds').asMinutes()) +
|
||||
'</h3><p> mins</p>';
|
||||
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 = '<h3>' + d + '</h3><p> day' + ((d > 1) ? 's' : '') + '</p>'
|
||||
+ '<h3>' + h + '</h3><p> hr' + ((h > 1) ? 's' : '') + '</p>'
|
||||
+ '<h3>' + m + '</h3><p> min' + ((m > 1) ? 's' : '') + '</p>';
|
||||
} else if (h > 0) {
|
||||
text = '<h3>' + h + '</h3><p> hr' + ((h > 1) ? 's' : '') + '</p>'
|
||||
+ '<h3>' + m + '</h3><p> min' + ((m > 1) ? 's' : '') + '</p>';
|
||||
} else {
|
||||
text = '<h3>0</h3><p> mins</p>';
|
||||
return text;
|
||||
text = '<h3>' + m + '</h3><p> min' + ((m > 1) ? 's' : '') + '</p>';
|
||||
}
|
||||
|
||||
return text
|
||||
}
|
||||
|
||||
String.prototype.toProperCase = function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue