mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 23:57:19 +02:00
Fix stream badge showing "1h60m" instead of "2h"
This commit is contained in:
parent
05eddce11e
commit
b7928ebe68
@ -158,19 +158,26 @@ export class StreamBadges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#secondsToHm(seconds: number) {
|
#secondsToHm(seconds: number) {
|
||||||
const h = Math.floor(seconds / 3600);
|
let h = Math.floor(seconds / 3600);
|
||||||
const m = Math.floor(seconds % 3600 / 60) + 1;
|
let m = Math.floor(seconds % 3600 / 60) + 1;
|
||||||
|
|
||||||
const hDisplay = h > 0 ? `${h}h`: '';
|
if (m === 60) {
|
||||||
const mDisplay = m > 0 ? `${m}m`: '';
|
h += 1;
|
||||||
return hDisplay + mDisplay;
|
m = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const output = [];
|
||||||
|
h > 0 && output.push(`${h}h`);
|
||||||
|
m > 0 && output.push(`${m}m`);
|
||||||
|
|
||||||
|
return output.join(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://stackoverflow.com/a/20732091
|
// https://stackoverflow.com/a/20732091
|
||||||
#humanFileSize(size: number) {
|
#humanFileSize(size: number) {
|
||||||
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||||
|
|
||||||
let i = size == 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024));
|
const i = size == 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024));
|
||||||
return (size / Math.pow(1024, i)).toFixed(2) + ' ' + units[i];
|
return (size / Math.pow(1024, i)).toFixed(2) + ' ' + units[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user