mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-07 08:07:18 +02:00
Simplify playtime text
This commit is contained in:
parent
e47c6d9103
commit
6c5fa3c061
@ -83,15 +83,13 @@ class StreamBadges {
|
|||||||
return $badge;
|
return $badge;
|
||||||
}
|
}
|
||||||
|
|
||||||
static #secondsToHms(seconds) {
|
static #secondsToHm(seconds) {
|
||||||
let h = Math.floor(seconds / 3600);
|
const h = Math.floor(seconds / 3600);
|
||||||
let m = Math.floor(seconds % 3600 / 60);
|
const m = Math.floor(seconds % 3600 / 60) + 1;
|
||||||
let s = Math.floor(seconds % 3600 % 60);
|
|
||||||
|
|
||||||
let hDisplay = h > 0 ? `${h}h`: '';
|
const hDisplay = h > 0 ? `${h}h`: '';
|
||||||
let mDisplay = m > 0 ? `${m}m`: '';
|
const mDisplay = m > 0 ? `${m}m`: '';
|
||||||
let sDisplay = s > 0 ? `${s}s`: '';
|
return hDisplay + mDisplay;
|
||||||
return hDisplay + mDisplay + sDisplay;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async render() {
|
static async render() {
|
||||||
@ -127,7 +125,7 @@ class StreamBadges {
|
|||||||
|
|
||||||
let now = +new Date;
|
let now = +new Date;
|
||||||
const diffSeconds = Math.ceil((now - StreamBadges.startTimestamp) / 1000);
|
const diffSeconds = Math.ceil((now - StreamBadges.startTimestamp) / 1000);
|
||||||
const playtime = StreamBadges.#secondsToHms(diffSeconds);
|
const playtime = StreamBadges.#secondsToHm(diffSeconds);
|
||||||
|
|
||||||
const BADGES = [
|
const BADGES = [
|
||||||
playtime ? ['playtime', playtime, '#ff004d'] : null,
|
playtime ? ['playtime', playtime, '#ff004d'] : null,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user