From fba49c3c893dbc8ce565efb77847f0bd3eca51ca Mon Sep 17 00:00:00 2001 From: Anthony Beaumont Date: Wed, 13 Jan 2021 03:21:42 +0700 Subject: [PATCH] humanize playtime --- service/watchdog/playtime/monitor.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/service/watchdog/playtime/monitor.js b/service/watchdog/playtime/monitor.js index 9a3560ae..d000b436 100644 --- a/service/watchdog/playtime/monitor.js +++ b/service/watchdog/playtime/monitor.js @@ -91,11 +91,16 @@ async function init(){ debug.log("playtime: " + Math.floor( playedtime / 60 ) + "min"); - const playedtimeHumanized = `You played for ${humanizeDuration(playedtime * 1000, { language: "en", conjunction: " and ", units: ["h", "m", "s"] })}`; + let humanized; + if (playedtime < 60) { + humanized = humanizeDuration(playedtime * 1000, { language: "en", units: ["s"] }); + } else { + humanized = humanizeDuration(playedtime * 1000, { language: "en", conjunction: " and ", units: ["h", "m"], round: true }); + } TimeTrack(game.appid,playedtime).catch((err)=>{debug.error(err)}); - emitter.emit("notify", [game, playedtimeHumanized]); + emitter.emit("notify", [game, "You played for " + humanized]); }