openhab/transform/sectohms.js

18 lines
556 B
JavaScript
Raw Normal View History

2021-01-19 11:38:39 +00:00
(function(seconds){
var retval = "";
var days = Math.floor(seconds / 3600 / 24)
var hours = Math.floor(seconds / 3600)
var minutes = Math.floor(seconds / 60)
hours = hours % 24
minutes = minutes % 60
seconds = seconds % 60
retval = retval + days + "d " + hours + "h ";
if (minutes < 10)
retval = retval + "0";
retval = retval + minutes + "m ";
if (seconds < 10)
retval = retval + "0";
retval = retval + seconds + "s";
return retval;
})(input)