From bc990cd683b169fd976774296f8a13df1361f746 Mon Sep 17 00:00:00 2001 From: Brian Choromanski Date: Sat, 4 Dec 2021 11:56:55 -0500 Subject: Format minutes from hours, and minutes to days, hours, and minutes --- src/popup.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/popup.ts') diff --git a/src/popup.ts b/src/popup.ts index 41bf1062..e11cb600 100644 --- a/src/popup.ts +++ b/src/popup.ts @@ -739,8 +739,9 @@ async function runThePopup(messageListener?: MessageListener): Promise { */ function getFormattedHours(minutes) { minutes = Math.round(minutes * 10) / 10 - const hours = Math.floor(minutes / 60); - return (hours > 0 ? hours + "h " : "") + (minutes % 60).toFixed(1); + const days = Math.floor(minutes / 3600) + const hours = Math.floor(minutes / 60) % 24; + return (days > 0 ? days + "d " : "") + (hours > 0 ? hours + "h " : "") + (minutes % 60).toFixed(1); } //end of function -- cgit v1.2.3 From 7bca8e508ede26a2e0fc8fce3198ec1c2f54f5f9 Mon Sep 17 00:00:00 2001 From: Brian Choromanski Date: Mon, 6 Dec 2021 05:57:37 -0500 Subject: Localized d and h --- public/_locales/en/messages.json | 6 ++++++ src/popup.ts | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/popup.ts') 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 e11cb600..88f4519c 100644 --- a/src/popup.ts +++ b/src/popup.ts @@ -731,17 +731,17 @@ async function runThePopup(messageListener?: MessageListener): Promise { } /** - * Converts time in hours to 5h 25.1 + * Converts time in hours to 2d 5h 25.1 * If less than 1 hour, just returns minutes * * @param {float} seconds * @returns {string} */ function getFormattedHours(minutes) { - minutes = Math.round(minutes * 10) / 10 - const days = Math.floor(minutes / 3600) + minutes = Math.round(minutes * 10) / 10; + const days = Math.floor(minutes / 3600); const hours = Math.floor(minutes / 60) % 24; - return (days > 0 ? days + "d " : "") + (hours > 0 ? hours + "h " : "") + (minutes % 60).toFixed(1); + return (days > 0 ? days + chrome.i18n.getMessage("dayAbbreviation") + " " : "") + (hours > 0 ? hours + chrome.i18n.getMessage("hourAbbreviation") + " " : "") + (minutes % 60).toFixed(1); } //end of function -- cgit v1.2.3