noctalia-shell/Helpers/Time.js
Sébastien Atoch 7639900f38 Bar/Battery: improved tooltip and handle negative charging rate
- Also slightly tweaked StyledTooltip minimum size to avoid
inconsistencies (Tooltip with a single line looked like pills instead of
rounded rectangles)
2025-08-03 22:51:01 -04:00

18 lines
487 B
JavaScript

function formatVagueHumanReadableTime(totalSeconds) {
const hours = Math.floor(totalSeconds / 3600);
const minutes = Math.floor((totalSeconds - (hours * 3600)) / 60);
const seconds = totalSeconds - (hours * 3600) - (minutes * 60);
var str = "";
if (hours) {
str += hours.toString() + "h";
}
if (minutes) {
str += minutes.toString() + "m";
}
if (!hours && !minutes) {
str += seconds.toString() + "s";
}
return str;
}