Closed keckelt closed 1 year ago
/**
* Translates seconds into human readable format of seconds, minutes, hours, days, and years
*
* @param {number} seconds The number of seconds to be processed
* @return {string} The phrase describing the amount of time
*/
function forHumans ( seconds ) {
var levels = [
[Math.floor(seconds / 31536000), 'years'],
[Math.floor((seconds % 31536000) / 86400), 'days'],
[Math.floor(((seconds % 31536000) % 86400) / 3600), 'hours'],
[Math.floor((((seconds % 31536000) % 86400) % 3600) / 60), 'minutes'],
[(((seconds % 31536000) % 86400) % 3600) % 60, 'seconds'],
];
var returntext = '';
for (var i = 0, max = levels.length; i < max; i++) {
if ( levels[i][0] === 0 ) continue;
returntext += ' ' + levels[i][0] + ' ' + (levels[i][0] === 1 ? levels[i][1].substr(0, levels[i][1].length-1): levels[i][1]);
};
return returntext.trim();
}
function formatTimeDuration(timestamp1, timestamp2) {
const diffInSeconds = Math.abs(Math.floor((timestamp2 - timestamp1) / 1000));
if (diffInSeconds < 60) {
return diffInSeconds + ' seconds';
} else if (diffInSeconds < 100 * 60) {
const diffInMinutes = Math.floor(diffInSeconds / 60);
return diffInMinutes + ' minutes';
} else if (diffInSeconds < 24 * 3600) {
const diffInHours = Math.floor(diffInSeconds / 3600);
return diffInHours + ' hours';
} else {
const diffInDays = Math.floor(diffInSeconds / (24 * 3600));
return diffInDays + ' days';
}
}
https://chat.openai.com/share/97eebe66-3856-4ec7-957e-bb94bdeac347
now using Github's relative time element
Currently only the version is shown
Show additional information like number of aggregated states, last execution, etc.