Skip to content

Commit

Permalink
humanize playtime
Browse files Browse the repository at this point in the history
  • Loading branch information
xan105 committed Jan 12, 2021
1 parent 2e01936 commit fba49c3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions service/watchdog/playtime/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

}

Expand Down

0 comments on commit fba49c3

Please sign in to comment.