diff options
author | Ajay Ramachandran <[email protected]> | 2021-12-11 19:39:28 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2021-12-11 19:39:28 -0500 |
commit | 7186829bc3072080fecf8b144ee391a54b0fe2e1 (patch) | |
tree | 36f4982e044be07a16de9d9c7fa982ee0419b8a6 | |
parent | 1c911581db2f617a4ae6f46c0eb53c840911a618 (diff) | |
parent | 33094f2541ae31d22cdcf3b903f396817875649c (diff) | |
download | SponsorBlock-7186829bc3072080fecf8b144ee391a54b0fe2e1.tar.gz SponsorBlock-7186829bc3072080fecf8b144ee391a54b0fe2e1.zip |
Merge pull request #1079 from Choromanski/feature/format-time-to-days
Format minutes now Days, Hours and Minutes
-rw-r--r-- | public/_locales/en/messages.json | 8 | ||||
-rw-r--r-- | src/popup.ts | 9 |
2 files changed, 13 insertions, 4 deletions
diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index f4285495..c56b3275 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -837,5 +837,13 @@ }, "fillerNewFeature": { "message": "New! Skip tangents and jokes with the filler category. Enable in options" + }, + "dayAbbreviation": { + "message": "d", + "description": "100d" + }, + "hourAbbreviation": { + "message": "h", + "description": "100h" } } 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 |