diff options
-rw-r--r-- | public/_locales/en/messages.json | 6 | ||||
-rw-r--r-- | src/popup.ts | 9 |
2 files changed, 11 insertions, 4 deletions
diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index f4285495..6215905f 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -837,5 +837,11 @@ }, "fillerNewFeature": { "message": "New! Skip tangents and jokes with the filler category. Enable in options" + }, + "dayAbbreviation": { + "message": "d" + }, + "hourAbbreviation": { + "message": "h" } } diff --git a/src/popup.ts b/src/popup.ts index bca6286d..84607e15 100644 --- a/src/popup.ts +++ b/src/popup.ts @@ -731,16 +731,17 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> { } /** - * Converts time in minutes to 5h 25.1 + * Converts time in minutes to 2d 5h 25.1 * If less than 1 hour, just returns minutes * * @param {float} minutes * @returns {string} */ function getFormattedHours(minutes) { - minutes = Math.round(minutes * 10) / 10 - const hours = Math.floor(minutes / 60); - return (hours > 0 ? hours + "h " : "") + (minutes % 60).toFixed(1); + minutes = Math.round(minutes * 10) / 10; + const days = Math.floor(minutes / 3600); + const hours = Math.floor(minutes / 60) % 24; + return (days > 0 ? days + chrome.i18n.getMessage("dayAbbreviation") + " " : "") + (hours > 0 ? hours + chrome.i18n.getMessage("hourAbbreviation") + " " : "") + (minutes % 60).toFixed(1); } //end of function |