mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 01:01:55 +01:00
Merge pull request #1079 from Choromanski/feature/format-time-to-days
Format minutes now Days, Hours and Minutes
This commit is contained in:
commit
7186829bc3
2 changed files with 13 additions and 4 deletions
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue